INSERTINTO department
(name, director, office, courses) VALUES
('English', 'Lynn Saunders', 'Breakstone Hall 205', CourseList(
'Expository Writing',
'Film and Literature',
'Modern Science Fiction',
'Discursive Writing',
'Modern English Grammar',
'Introduction to Shakespeare',
'Modern Drama',
'The Short Story',
'The American Novel'));
DECLARE
new_courses CourseList :=
CourseList('Expository
Writing',
'Film and Literature',
'Discursive Writing',
'Modern English Grammar',
'Realism and Naturalism',
'Introduction to Shakespeare',
'Modern Drama',
'The Short Story',
'The American Novel',
'20th-Century Poetry',
'Advanced Workshop in Poetry'); BEGIN UPDATE department
SET courses = new_courses WHERE name = 'English'; END;
/
You cannot directly drop the storage table of a nested table.
Instead, you must drop the nested table column using the ALTER
TABLE ... DROP COLUMN clause.
To select data from a nested table column you use the
TABLE function to treat the nested table as columns of a table. This process is called "collection unnesting".
SELECT t1.department_id, t2.* FROM hr_info t1, TABLE(t1.people) t2 WHERE t2.department_id = t1.department_id;
SELECT t1.name, t2.* FROM department t1, TABLE(t1.courses) t2;
Nested Table Demos
Constructor for a Nested Table
In the following example, you pass multiple elements
to the constructor CourseList(), which returns a nested table containing those elements: