Wednesday, May 28, 2008

Where is my Column data? SQL*plus does not show

If you have any CLOB or NCLOB or LONG column in a table then while you query the column from SQL*plus the column data is truncated before displayed. SQL*plus by default only shows the first 80 bytes of any LONG, CLOB and NCLOB datatypes. The data is actually in the table, but since sqlplus tries not to print out too much data so it displays 80 bytes only.

We can change this behavour of SQL*plus by setting SET LONG. With an example I have demonstrate this behavior.
SQL> CREATE TABLE LONG_TEST(COL1 CLOB);
Table created.

SQL> INSERT INTO LONG_TEST VALUES('This line is more than 80 bytes. So some of the parts of this line will not be shown if I don''t set LONG');
1 row created.

SQL> SELECT * FROM LONG_TEST;


COL1
--------------------------------------------------------------------------------
This line is more than 80 bytes. So some of the parts of this line will not be s

SQL> SET LONG 500
SQL> SELECT * FROM LONG_TEST;

COL1
--------------------------------------------------------------------------------
This line is more than 80 bytes. So some of the parts of this line will not be s
hown if I don't set LONG

No comments:

Post a Comment