7.10 Loading Objects, Collections, and LOBs with SQL*Loader

You can bulk-load the column, row, LOB, and JSON database objects that you need to model real-world entities, such as customers and purchase orders.

7.10.1 Supported Object Types

SQL*Loader supports loading of the column and row object types.

7.10.1.1 column objects

When a column of a table is of some object type, the objects in that column are referred to as column objects.

Conceptually such objects are stored in their entirety in a single column position in a row. These objects do not have object identifiers and cannot be referenced.

If the object type of the column object is declared to be nonfinal, then SQL*Loader allows a derived type (or subtype) to be loaded into the column object.

7.10.1.2 row objects

These objects are stored in tables, known as object tables, that have columns corresponding to the attributes of the object.

The object tables have an additional system-generated column, called SYS_NC_OID$, that stores system-generated unique identifiers (OIDs) for each of the objects in the table. Columns in other tables can refer to these objects by using the OIDs.

If the object type of the object table is declared to be nonfinal, then SQL*Loader allows a derived type (or subtype) to be loaded into the row object.

7.10.2 Supported Collection Types

SQL*Loader supports loading of nested tables and VARRAY collection types.

7.10.2.1 Nested Tables

A nested table is a table that appears as a column in another table.

All operations that can be performed on other tables can also be performed on nested tables.

7.10.2.2 VARRAYs

A VARRAY is a variable sized arrays.

An array is an ordered set of built-in types or objects, called elements. Each array element is of the same type and has an index, which is a number corresponding to the element's position in the VARRAY.

When you create a VARRAY type, you must specify the maximum size. Once you have declared a VARRAY type, it can be used as the data type of a column of a relational table, as an object type attribute, or as a PL/SQL variable.

See Also:

Loading Collections (Nested Tables and VARRAYs) for details on using SQL*Loader control file data definition language to load these collection types

7.10.3 SODA Collections and SQL*Loader

SQL*Loader enables you to load external documents into SODA collections using the SQL*Loader utility in both control file and express modes.

Starting with Oracle Database 23ai, you can use SQL*Loader to load schemaless documents (documents that lack a fixed data structure, such as JSON or XML-based application data) into Oracle Database as SODA collections. A SODA (Simple Oracle Document Access) collection is a set of documents that is backed by an Oracle Database table or view. A document is stored in Oracle Database as a row in a table or view, with each component in its own column.

When you create a SODA document collection, the following is created in Oracle Database:

  • Persistent default collection metadata.
  • A table for storing the collection.

You can insert, append, and replace external documents into SODA collections in Oracle Database applications

To load a SODA collection, you supply one to three pieces of information to the SQL*Loader utility:

  • $CONTENT: The content that you want to load (Required).

    This field can be an actual text document, or a secondary data file containing one or more documents. There are two types of content that you can specify:

    • RAW(*): Use the RAW(*) data field either when text documents are stored directly in the control or data file, or when the documents are specified in the INFILE clause.
    • CONTENTFILE(soda_filename): use the CONTENTFILE name to specify an secondary data file name (soda_filename) from which you want SQL*Loader to load the data. One or more documents can be contained in the secondary data file that you specify.
  • $KEY: A key to identify the document (Optional)

    In a collection, each document must have a document key, which is unique for the collection. However, you do not need to provide a key if the SODA collection automatically generates keys. If $KEY is specified, then there is a one-to-one relationship between the key and the content.

  • $MEDIA: A media type to describe the type of the content (Optional)

    $MEDIA is not required if the SODA collection is defined to hold documents of one media type. The default media type is JSON but this can be modified using the SODA_MEDIA keyword.

7.10.4 Supported LOB Data Types

SQL*Loader supports multiple large object types (LOBs).

This release of SQL*Loader supports loading of four LOB data types:

  • BLOB: a LOB containing unstructured binary data

  • CLOB: a LOB containing character data

  • NCLOB: a LOB containing characters in a database national character set

  • BFILE: a BLOB stored outside of the database tablespaces in a server-side operating system file

LOBs can be column data types, and except for NCLOB, they can be an object's attribute data types. LOBs can have an actual value, they can be null, or they can be "empty."

JSON columns can be loaded using the same methods used to load scalars and LOBs

See Also:

Loading LOBs for details on using SQL*Loader control file data definition language to load these LOB types