2016年4月17日 星期日

Nested Table Example 01

/**
   Demo the nested table. Use it in the schema. 
*/
-- Create a nested table type 
create or replace type scores_type as table of number;
/

-- Create a table with a nested table
-- You need to specify the table name for the nested table using
-- "nested table store as" clause.
create table student_scores (s_id number, scores scores_type)
nested table scores store as scores_tab;
/
-- 
select * from student_scores;

-- Insert values 
-- Use the type name as the constructor to create scores_type instances and store them
-- in the scores_tab table
insert into student_scores values (10, scores_type(100, 100));

-- Update
update student_scores
set scores = scores_type(90,100);

commit;

沒有留言: