Because a smart large object can be quite large, it is
not practical to store it directly in the database table. Instead,
the INSERT and UPDATE statements store the LO handle of the smart
large object in the CLOB, BLOB, or opaque-type column. The data of
the smart large object is in an sbspace.
To save a smart large object in a CLOB, BLOB, or opaque-type
column:
- For a new smart large object, ensure that the smart large
object has an sbspace specified for its data.
For most
smart large objects, the sbspace name is the only storage characteristic
that you need to specify. The smart-large-object optimizer can calculate
values for all other storage characteristics. You can set particular
storage characteristics to override these calculated values. However,
most applications do not need to set storage characteristics at this
level of detail. For more information, see Obtaining storage characteristics.
- Create a new LO handle for the smart large object and open
the smart large object.
When you create a smart large
object, you obtain an LO handle and an LO file descriptor for the
new smart large object.
- Write the smart-large-object data to the sbspace of the
smart large object.
Use the LO file descriptor to identify
the smart large object whose data you want to write to the sbspace.
- Use the INSERT or UPDATE statement to store the LO handle
into the CLOB, BLOB, or opaque-type column.
The LO handle
for the smart large object identifies the location of the smart large
object on disk. After you have written the data to the smart large
object, provide its LO handle to the INSERT or UPDATE statement to
save it in the database. The smart-large-object data remains in the
sbspace.
Important: The sbspace for the
smart large object must exist before the INSERT statement executes.
When you store an LO handle in the database, the database
server can ensure that the smart large objects are only freed when
no more database columns reference them. For more information, see Delete a smart large object. For information
about how to insert a smart large object from within a DataBlade
API module,
see Creating a smart large object.