Large Objects   «Prev  Next»

Lesson 7 Temporary LOBs
ObjectiveUnderstand how and why to use temporary LOBs

How and why to use Temporary LOBs

A temporary LOB is a way to store a LOB in a temporary tablespace. These temporary LOBs, by default, last only for the duration of a session. You would typically use a temporary LOB when you are performing a number of operations on a LOB (such as morphing an image) and you want to keep a complete copy of the LOB temporarily.

How to use temporary LOB

You create and manipulate temporary LOBs with procedures from the DBMS_LOB package. These procedures are as follows:
Procedure Description
DBMS_LOBCREATETEMPORARYThis procedure creates a temporary LOB. You can specify whether you want a temporary LOB to last for the duration of the session or the duration of the particular call.
code>DBMS_LOB.FREETEMPORARY This procedure frees the space used by a temporary LOB and invalidates the LOB locator for the temporary LOB.
DBMS_LOB.ISTEMPORARY This procedure checks to see if a particular LOB is a temporary or permanent LOB.

When you create a temporary LOB, it is empty. You can use the DBMS_LOB.COPY() function to move the contents of a permanent LOB into a temporary LOB. The specific temporary LOB operations are illustrated in the following Slide Show:
1) Temporary Lob 1 2) Temporary Lob 2 3) Temporary Lob 3

Create Temporary Lobs
You can also use most of the manipulation functions in the DBMS_LOB package on temporary LOBs.
Once a temporary LOB is created, you can use it as a value in a WHERE clause for UPDATE, INSERT, and DELETE statements, or as a location to SELECT INTO. If you select into a temporary LOB from a permanent LOB, the LOB locator for the permanent LOB overwrites the temporary LOB locator, rather than copying the value of the permanent LOB into the temporary LOB.
In the next lesson, you will learn about buffering options for LOBs.