Creating a Varray Type

A varray stores an ordered set of elements in the same type. The type can be a built-in database type or a user-defined object type. Each element is indexed by its position in the array. You can change elements only as a whole. The following example creates a type named t_varray that can store up to three VARCHAR2 strings:


SQL> CREATE TYPE t_varray AS VARRAY(3) OF VARCHAR2(50);
  2  /

Type created.

SQL>

You can change the maximum number of elements of a varray using the ALTER TYPE statement.


SQL> ALTER TYPE t_varray MODIFY LIMIT 10 CASCADE;

Type altered.

SQL>

The CASCADE option propagates the change to any dependent objects in the database.

Home »
Oracle »
PL/SQL » 

Varrays:
  1. Creating a Varray Type
  2. Using a Varray Type to Define a Column
  3. Getting Information on a Varray
  4. Populating a Varray with Elements
  5. Retrieving Elements from a Varray
  6. Using TABLE() to Treat a VArrays
  7. Modifying Elements of a Varray
Related: