Choosing Between the Three Collection Types
Associative arrays are PL/SQL-only key-value maps; nested tables and VARRAYs can also be stored in columns.
How it works
Associative array (TABLE OF ... INDEX BY PLS_INTEGER or VARCHAR2): no initialisation or EXTEND, can be sparse, cannot be a table column or used directly in SQL — ideal as an in-memory lookup or a FORALL/BULK COLLECT buffer. Nested table (TABLE OF ...): starts empty/atomically null, needs a constructor and EXTEND, can be dense or sparse, can be a column and used with MULTISET/TABLE(). VARRAY (VARRAY(n) OF ...): bounded maximum size, always dense, order preserved, good for a short fixed list stored inline in a row.
DECLARE
TYPE map_t IS TABLE OF NUMBER INDEX BY VARCHAR2(30); -- associative
TYPE ntab_t IS TABLE OF NUMBER; -- nested table
TYPE varr_t IS VARRAY(5) OF NUMBER; -- varray
m map_t;
n ntab_t := ntab_t();
v varr_t := varr_t(10, 20, 30);
BEGIN
m('EUR') := 1.09;
n.EXTEND; n(1) := 42;
DBMS_OUTPUT.PUT_LINE(m('EUR') || ' ' || n(1) || ' ' || v(2));
END;
/Related questions
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.