An associative array (formerly called PL/SQL table or index-by table) is a set of key-value pairs. Each key is a unique index, used to locate the associated value with the syntax variable_name(index) .
The data type of index can be either a string type or PLS_INTEGER . Indexes are stored in sort order, not creation order.
Like a database table, an associative array:
- Is empty (but not null) until you populate it
- Unbounded, grow dynamically as elements are added.
Unlike a database table, an associative array:
Used for :
- intended for temporary data storage such as a small lookup table which can be constructed in memory each time you invoke the subprogram or initialize the package that declares it
- Passing collections to and from the database server
|
In the database, a nested table is a column type that stores an unspecified number of rows in no particular order.
A nested table definition does not allocate space. It defines a type, which you can use to declare:
- The datatype of a column of a relational table
- An object type attribute
- A PL/SQL variable, parameter, or function return type
A nested table is appropriate when:
- The number of elements is not set.
- Index values are not consecutive.
- You must delete or update some elements, but not all elements simultaneously.
Nested table data is stored in a separate store table, a system-generated database table. When you access a nested table, the database joins the nested table with its store table. This makes nested tables suitable for queries and updates that affect only some elements of the collection.
- You would create a separate lookup table, with multiple entries for each row of the main table, and access it through join queries.
| An array is an ordered set of homogeneous data elements. Oracle arrays are of variable size, which is why they are called varrays.
Bounded, Maximum size must be defined at the time of creation.
When you declare a varray, it does not allocate space. It defines a type, which you can use as:
- The datatype of a column of a relational table
- An object type attribute
- A PL/SQL variable, parameter, or function return type
A varray is appropriate when:
Because you must store or retrieve all elements at the same time, a varray might be impractical for large numbers of elements.
|
3. Individual elements can be deleted, hence it can be a sparse collection. The elements need not be consecutive at creation. | A nested array is dense initially, but it can become sparse, because you can delete elements from it. | is always dense,individual elements cannot be deleted. |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.