Collections in SQL are one dimensional and are similar to arrays
VARRAYs have an upper bound on the size
Nested Table
Similar to array. Index starts from 1
COUNT can be used to find the size of the nested table
How To Create Nested Table As Database Object In Oracle | RebellionRider
VARRAYs
The LIMIT keyword is used to access the upper limit of the VARRAY
The EXTEND keyword is used to initialize the VARRAY. When used outside the loop we use EXTEND(n) when using inside the loop for dynamic allocation we just use EXTEND
The values can be directly specified in the initialization step as well
Introduction To PL/SQL VARRAYs In Oracle Database | RebellionRider
How To Create VARRAYs As Database Object In Oracle Database | RebellionRider
Associative Array
Similar to dictionary (key, value) pair from other programming languages
Functions
COUNT: Can be used in For loop as upper bound. Returns the number of elements that are present in the collection (Used with Nested Table)
EXISTS(n) : Used to check if an value is present at an index
FIRST, LAST: Returns the first and last element of an collection. Returns NULL if collection does not have value. Error if Index does not exist
LIMIT: Can be used in for loop as upper bound. Returns the size of the VARRAY
PRIOR(n), NEXT(n): Returns the previous and next index
Procedures
DELETE, DELETE(n), DELETE(start, end): Deletes an value at an index from the collection
EXTEND, EXTEND(n), EXTEND(n, v): It is used to assign memory. Attach a single NULL value. Append NULL n times. Append n times the value at index v. Cannot be used with associative arrays
TRIM, TRIM(n): Remove 1 element from end. Remove n elements from end