Explain Varrays with example
In : MCA Subject : Advanced Database AdministrationVARRAY is a variable array type that is commonly used when storing a small number of instances. It consists of a number of data pieces, all of which are of the same data type. The number of elements is determined by the size of VARRAY.
Example:
Defining a VARRAY object
CREATE OR REPLACE TYPE ProjectList AS VARRAY(50) OF Project;
special type is the VARRAY or varying array type. This type should be used when the number of instances to be stored is small. This type is stored inline with the other table data. In early releases the varray could take up to 25 times the amount of storage as a nested table for the same values.
rem There is a fixed number of FTX codes and it is small
rem so use a VARRAY
rem
CREATE OR REPLACE TYPE ftx_t (
ftx_code CHAR(8) ,
ftx_code_desc VARCHAR2(32),
primary_ftx_code_ind CHAR(1)
);
rem
rem ftx_v is a VARRAY of 6 elements
rem
CREATE OR REPLACE TYPE ftx_v AS VARRAY(6) OF ftx_t;
Notice that the number of instances of the VARRAY is set at six(6) in this example. This required 676 bytes of RAW inline storage. You have no control over storage and can not index or constrain varray values.