Unloading LONG and LONG RAW Data Types

The ORACLE_DATAPUMP access driver can be used to unload LONG and LONG RAW columns, but that data can only be loaded back into LOB fields. The steps in the following extended example demonstrate the unloading of LONG and LONG RAW data types.

  1. If a table to be unloaded contains a LONG or LONG RAW column, then define the corresponding columns in the external table as CLOB for LONG columns or BLOB for LONG RAW columns.
    SQL> CREATE TABLE long_tab
      2  (
      3    key                   SMALLINT,
      4    description           LONG
      5  );
    
    Table created.
    
    SQL> INSERT INTO long_tab VALUES (1, 'Description Text');
    
    1 row created.
    
  2. Now, an external table can be created that contains a CLOB column to contain the data from the LONG column. Note that when loading the external table, the TO_LOB operator is used to convert the LONG column into a CLOB.
    SQL> CREATE TABLE long_tab_xt
      2  ORGANIZATION EXTERNAL
      3  (
      4    TYPE ORACLE_DATAPUMP
      5    DEFAULT DIRECTORY def_dir1
      6    LOCATION ('long_tab_xt.dmp')
      7  )
      8  AS SELECT key, TO_LOB(description) description FROM long_tab;
    
    Table created.
    
  3. The data in the external table can be used to create another table exactly like the one that was unloaded except the new table will contain a LOB column instead of a LONG column.
    SQL> CREATE TABLE lob_tab
      2  AS SELECT * from long_tab_xt;
    
    Table created.
    
  4. Verify that the table was created correctly.
    SQL> SELECT * FROM lob_tab;
    
           KEY  DESCRIPTION
    ----------------------------------------------------------------------------
             1  Description Text