Large Objects   «Prev 

TO_LOB function in Oracle

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
  1. LONG and
  2. 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.

TO_LOB
INSERT INTO lob_table
  SELECT column_list
  TO_LOB long_column
  FROM long_table
Oracle TO_LOB

INSERT INTO Required keywords.
lob_table The new table with the LOB data type. This table must exist before using this statement.
SELECT Required keyword
column_listA list of non-LONG columns
TO_LOB The required function
long_columnThe LONG or LONG RAW column that is to be converted
FROMRequired keyword
long_table The original table containing the LONG or LONG RAW column