Syntax for Declaring Collection Datatypes

As noted earlier, you must first declare or create a collection datatype before you can create collections based on that type.

To create a nested table datatype that lives in the data dictionary, specify:

CREATE [ OR REPLACE ] TYPE <type name> AS TABLE OF <element datatype> [ NOT NULL ];

To create a VARRAY datatype that lives in the data dictionary:

CREATE [ OR REPLACE ] TYPE <type name> AS VARRAY (<max elements>) OF <element datatype> [ NOT NULL ];

To drop a type:

DROP TYPE <type name> [ FORCE ];

To declare a nested table datatype in PL/SQL:

TYPE <type name> IS TABLE OF <element datatype> [ NOT NULL ];

To declare a VARRAY datatype in PL/SQL:

TYPE <type name> IS VARRAY (<max elements>) OF <element datatype> [ NOT NULL ];

Where:

Note that the only syntactic difference between declaring nested table types and index-by table types in a PL/SQL program is the absence of the INDEX BY BINARY_INTEGER clause.

The syntactic differences between nested table and VARRAY type declarations are: