LONG RAW

From Oracle FAQ
⧼orafaq-jumptonavigation⧽⧼orafaq-jumptosearch⧽

LONG RAW is an Oracle data type for storing binary data of variable length up to 2 Gigabytes in length. Note that a table can only have one LONG RAW column.

History[edit]

Since Oracle 8i, Oracle advised against using the LONG RAW datatype. Users should convert to the BLOB data type.

Example[edit]

SQL> CREATE TABLE t1(id NUMBER, doc LONG RAW);
Table created.
SQL> INSERT INTO t1 VALUES (1, utl_raw.cast_to_raw('Test to go into LONG RAW column'));
1 row created.

Note: SQL*Plus is unable to SELECT a LONG RAW column, you have to write your own program (in C, Java, VB, PHP or whatever supports OCI or OO4O).

Convert to newer BLOB type[edit]

Following from the above example, use the TO_LOB function to convert the LONG RAW column to a BLOB:

CREATE TABLE t1_new(id NUMBER, doc BLOB);
INSERT INTO t1_new SELECT id, TO_LOB(doc) FROM t1;
DROP TABLE t1;
RENAME t1_new to t1;

Also see[edit]