BLOB

From Oracle FAQ
Jump to: navigation, search

A BLOB (Binary Large Object) is an Oracle data type that can hold up to 4 GB of data. BLOB's are handy for storing digitized information (e.g., images, audio, video).

Examples[edit]

Create a table containing a BLOB column:

CREATE TABLE lob_table (id NUMBER, doc BLOB);
INSERT INTO lob_table VALUES (1, EMPTY_BLOB()); 

Load an external file into the table:

DECLARE
  src_lob  BFILE := BFILENAME('MY_DIR', '/tmp/me.gif');
  dest_lob BLOB;
BEGIN
  INSERT INTO lob_table VALUES(2, EMPTY_BLOB())
     RETURNING doc INTO dest_lob;

  DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);
  DBMS_LOB.LoadFromFile( DEST_LOB => dest_lob,
                         SRC_LOB  => src_lob,
                         AMOUNT   => DBMS_LOB.GETLENGTH(src_lob) );
  DBMS_LOB.CLOSE(src_lob);

  COMMIT;
END;
/

Also see[edit]

  • CLOB - Character large Object
  • NCLOB - similar to CLOB, but characters are stored in a multibyte national character set
Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #