Chapter 5. Collections
Traditionally, a master-detail relationship between two database tables is enforced using a foreign key constraint. Oracle also enables this relationship to be modeled using a class of database types known as a collection, which is a set of data elements. There are two types of collections. The first is known as a VARRAY, which enables a variable-length array to be stored within a table. The second is a nested table, which enables a table to be stored within another table. These collection types allow rows that make up the detail part of a relationship to be grouped with the master rows.
In this chapter, you will learn how to create collection types and how to create tables that contain collections. You will also learn how to retrieve, add, and modify collections using both SQL and SQLJ statements. The statements that create and populate the database objects referred to in this chapter are contained in the SQL*Plus script object_user_schema.sql. If you haven't already run this script, you or your DBA must do so if you wish to run the example programs.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access