Long Types-Datatypes

LONG types come in two flavors in Oracle:

•\ A LONG text type capable of storing 2GB of text. The text stored in theLONG type is subject to character set conversion, much like a VARCHAR2or CHAR type.
•\ A LONG RAW type capable of storing 2GB of raw binary data (data thatis not subject to character set conversion).

The LONG types date back to version 6 of Oracle, when they were limited to 64KB of data. In version 7, they were enhanced to support up to 2GB of storage, but by the time version 8 was released, they were superseded by the LOB types, which we will discuss shortly.

Rather than explain how to use the LONG type, I will explain why you do not want to use the LONG (or LONG RAW) type in your applications. First and foremost, the Oracle documentation is very clear in its treatment of the LONG types. The Oracle Database SQL Language Reference manual states the following:

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


Restrictions on LONG and LONG RAW Types

The LONG and LONG RAW types are subject to the restrictions outlined in Table 12-2. Even though it might be considered jumping ahead, I’ve added a column to say whether the corresponding LOB type, which is the replacement for the LONG/LONG RAW types, is subject to the same restriction.

Table 12-2.  Long Types Compared to LOBs

Table 12-2.  (continued)

As you can see, Table 12-2 presents quite a long list; there are many things you just cannot do when you have a LONG column in the table. For all new applications, do not even consider using the LONG type. Instead, use the appropriate LOB type. For existing applications, you should seriously consider converting the LONG type to the corresponding LOB type if you are hitting any of the restrictions in Table 12-2. Care has been taken to provide backward compatibility so that an application written for LONG types will work against the LOB type transparently.

Note It almost goes without saying that you should perform a full functionality test against your application(s) before modifying your production system from LONG to LOB types.

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*

BACK TO TOP