Sunday, November 2, 2008

BLOB datatype in Oracle

LOB OBJECT:
Here is a table I will use for the rest of this entry:
CREATE TABLE large_objects (
char_data CLOB,
binary_data BLOB,
ext_binary_data BFILE
)

A BLOB is a LOB for binary data. You might store pictures or word processing file in a BLOB field. You can use DBMS_LOB to load a blob into a BLOB field. You can also use UTL_RAW to convert char data to RAW.
insert into large_objects (binary_data)
values (utl_raw.cast_to_raw('This is a lob even though it''s small'));

select binary_data,
utl_raw.cast_to_varchar2(binary_data) bin_data,
dbms_lob.getlength(binary_data) len_bin_data
from large_objects;


binary_data                   bin_data                         LEN_BIN_DATA
------------------------------ ------------------------------ ------------
                                     This is a lob even though it's 36
                                      small
1 row selected.

No comments:

search engine

Custom Search