In Oracle, the appropriate data types for storing large objects are the
- BLOB,
- CLOB, and
- NCLOB data types.
In earlier versions of Oracle, the LONG and LONG RAW data types were used for the same purposes.
There are a number of differences between the ways a LONG or LONG RAW column can be used and the way a column with any of the LOB data types can be used. Some of these differences are:
- LONGs can contain only up to 2 GB of data, whereas the LOB data types can contain up to 4 GB.
- You can only have 1 LONG column per table, but you can have more than one LOB per table.
- When a LOB is selected, only the locator for the LOB is returned.
- A LOB can be part of an object type, whereas a LONG cannot.
- You can use a LOB as a bind variable, whereas you cannot use a LONG as a bind variable.
Because of the increased capability of LOBs, and because Oracle will probably discontinue support for the LONG data types in the future, Oracle
recommends that you convert existing LONG and LONG RAW columns to a LOB data type.
The TO_LOB function is still used in Oracle performance tuning, but it is less commonly used than it once was.
This is because there are now other, more efficient ways to convert LONG and LONG RAW data to LOB data.
The TO_LOB function was introduced in Oracle 8i and was originally the only way to convert
- LONG and
- LONG RAW
data to LOB data. However, in Oracle 9i, the DBMS_LOB package was introduced, which provides a more efficient way to convert LONG and LONG RAW data to LOB data. The DBMS_LOB package also provides a number of other LOB-related functions, such as the ability to create, read, write, and delete LOB data.
In addition to the DBMS_LOB package, there are now a number of third-party tools that can be used to convert LONG and LONG RAW data to LOB data. These tools can often be more efficient than the TO_LOB function, especially for large amounts of data.
As a result of these newer, more efficient methods, the TO_LOB function is now less commonly used in Oracle performance tuning. However, it is still a valid option, and it may be the best option in some cases.
Here are some of the reasons why the TO_LOB function is still used:
- It is a simple and easy-to-use function.
- It is supported by all Oracle versions from 8i onwards.
- It is compatible with all LOB types.
Here are some of the reasons why the TO_LOB function is not as commonly used as it once was:
- It is less efficient than the DBMS_LOB package and third-party tools.
- It is not as versatile as the DBMS_LOB package and third-party tools.
- It is not as scalable as the DBMS_LOB package and third-party tools.
If you are considering using the TO_LOB function, I recommend that you first try to use the DBMS_LOB package or a third-party tool. If these options are not available or do not meet your needs, then you can use the TO_LOB function.
The following diagram describes the TO_LOB function, which was introduced in Oracel 8i.