LONG RAW

From Oracle FAQ
Jump to: navigation, search

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.

Contents

[edit] History

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

[edit] Example

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).

[edit] Convert to newer BLOB type

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;

[edit] Also see