Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle: LONG or CLOB?

From these two threads,

  • Why is LONG an issue with Oracle?
  • Is it possible to read a CLOB from a remote Oracle database?

LONG is archaic and deprecated. Oracle says,

Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB) instead. LONG columns are supported only for backward compatibility.

Oracle also recommends that you convert existing LONG columns to LOB columns. LOB columns are subject to far fewer restrictions than LONG columns. Further, LOB functionality is enhanced in every release, whereas LONG functionality has been static for several releases.

But you cannot read a CLOB from a remote database without the workarounds mentioned here.

Which one should I prefer to store some text in my tables? Or is there a better solution than these two?

like image 746
Moeb Avatar asked Aug 30 '10 09:08

Moeb


People also ask

What is the datatype for long in Oracle?

The LONG datatype stores variable-length character strings containing up to two gigabytes, but with many restrictions. This datatype is provided for backward compatibility with existing applications; in general, new applications should use CLOB and NCLOB datatypes to store large amounts of character data.

What is bigger than CLOB in Oracle?

The four large object data types BFILE, BLOB, CLOB, and NCLOB all store up to 4 GB of data.


2 Answers

Use CLOBs. One limitation of LONG is that LONGs can't be handled correctly from SQL - PL/SQL.

For a more detailed description of the differences, see http://www.comp.dit.ie/btierney/oracle11gdoc/appdev.111/b28393/adlob_tables.htm#insertedID2

like image 141
gpeche Avatar answered Oct 29 '22 20:10

gpeche


If Oracle says a feature is deprecated it may not be available any longer in a future release. So unless your application will run on the current Oracle version for an unlimited amount of time, don't use deprecated functionality.

like image 36
Rene Avatar answered Oct 29 '22 22:10

Rene