VARRAY on Oracle


srcnblgc

Creating a Varray Type:

  1. A varray stores an ordered set of elements.
  2. Each element has an index associated with it.
  3. A varray has a maximum size that you can change dynamically.
You create a varray type using the SQL DDL CREATE TYPE statement.
You specify the maximum size and the type of elements stored in the varray when creating the
The basic Oracle syntax for the CREATE TYPE statement for a VARRAY type definition would be:
CREATE OR REPLACE TYPE name-of-type IS VARRAY(nn)of type
Where name-of-type is a valid attribute name, nn is the number of elements (maximum) in the array, and type is the data type of the elements of the array.
You can change the maximum size of a varray using the ALTER TYPE statement.
SQL> CREATE Or Replace TYPE addressVarray AS VARRAY(2OF VARCHAR2(50);
  2  /
Type created.SQL>
SQL> desc addressVarray;
 addressVarray VARRAY(2OF VARCHAR2(50

View original post 273 more words