LONG

From Oracle FAQ
Jump to: navigation, search

LONG is an Oracle data type for storing character data of variable length up to 2 Gigabytes in length (bigger version of the VARCHAR2 datatype). Note that a table can only have one LONG column.

Contents

[edit] History

Since Oracle 8i, Oracle advised against using the LONG datatype. Users should convert to CLOB or NCLOB types.

[edit] Example

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

[edit] Convert to newer CLOB/NCLOB type

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

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

[edit] Also see