| Lesson 6 | Large varrays and LOBs |
| Objective | Describe how Oracle 23ai uses LOBs to store large varrays |
VARRAY (variable-size array). A VARRAY is stored as a single logical value in a column or object attribute.
That “single value” property is the reason Oracle sometimes stores the VARRAY inline in the row and sometimes stores it
out-of-line in a LOB segment.
The sizing rule is straightforward in practice: if a VARRAY can fit in the row, Oracle can store it inline; if it becomes too large, it must be stored out-of-line. Out-of-line storage uses the same LOB infrastructure you’ve been learning in this module: a LOB segment plus a locator stored in the base table row.
Oracle provides two main collection types:
A VARRAY is often the right choice when you typically fetch the entire collection as part of the parent row (for example, “give me the customer and all phone numbers”), rather than searching for individual elements inside the collection.
Conceptually, the shift looks like this:
The practical implication (and the tuning connection) is that inline VARRAYs can make scans more expensive because the row is larger, while out-of-line storage can make point reads more expensive because Oracle must follow the locator to a separate segment. Your goal is to choose an approach that matches access patterns and expected collection size.
That means a “large VARRAY” inherits all the LOB design decisions from earlier lessons:
CREATE TYPE typename AS VARRAY (n) OF datatype;
| CREATE TYPE | Required keywords for defining a type. |
| typename | Unique name for the type. |
| AS VARRAY | Required keywords for declaring a VARRAY collection. |
| n | Maximum number of elements allowed in the VARRAY. |
| OF | Required keyword. |
| datatype | Datatype of each element. This can be a built-in scalar datatype or an object type. It cannot be another VARRAY type or nested table type. |
CREATE TYPE NumberList AS VARRAY(100000) OF NUMBER;
/
CREATE TABLE big_array_table (
id NUMBER,
data NumberList
)
VARRAY data STORE AS LOB (
STORE AS SECUREFILE (
CHUNK 8192
NOCACHE
RETENTION AUTO
)
);
In this pattern:
data NumberList to the application.
If you need to verify how Oracle stored a given VARRAY-as-LOB implementation, the same metadata views you use for LOBs apply:
USER_LOBS/DBA_LOBS for LOB configuration, and USER_SEGMENTS/DBA_SEGMENTS for space usage.
The “VARRAY stored as LOB” feature is essentially Oracle bridging object-style modeling (collections as attributes) with physical storage strategies that keep row sizes manageable when the collection grows beyond inline comfort.
CREATE TYPE phone_array AS VARRAY(10) OF VARCHAR2(15);
This allows up to 10 phone numbers (15 characters each) to be stored as a single attribute in a table row or object type,
such as a customer_type. If your design grows beyond small collections (for example, thousands of entries per row),
you either explicitly store the VARRAY as a LOB or re-evaluate the design and consider a nested table or a child table.
In the next lesson, you will learn about temporary LOBs and why they matter for high-throughput LOB processing workflows.