Chapter 12. Streaming Data Types

Most of the time, the 4,000 bytes of storage available with the VARCHAR2 data type under Oracle8 and higher is sufficient for application needs. But occasionally, applications require larger text fields or need to store complex binary data types such as word processing files and photo images in the database. Oracle8’s solution to the problem of storing large amounts of data is the binary file (BFILE), binary large object (BLOB), and character large object (CLOB) data types. These large object (LOB) data types ease the storage restriction to 4 GB. The difference between a CLOB and a BLOB is that a CLOB is subject to character set translation as part of Oracle’s National Language Support (NLS), whereas a BLOB’s data is taken verbatim.

Oracle7’s solution to the problem of storing large amounts of data is the LONG and LONG RAW data types. A LONG column can hold up to 2 GB of character data, while a LONG RAW can hold up to 2 GB of binary data. However, the truth of the matter is that LONGs exist in Oracle8 and higher only for the purpose of backward compatibility.

I recommend you use the BLOB and CLOB data types for all new development when you need to store more than 4,000 bytes of data for a column. Collectively, LOBs are normally transferred between your application and the database using streams instead of the get/set accessor methods used for VARCHAR2 and other types. Consequently, LOBs are also referred to as streaming data types.

Tip

Throughout this ...

Get Java Programming with Oracle JDBC now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.