我有一个超类型Person和两个(或更多)子类型Group1和Group2。
Person可以是Group1和Group2,即子类型可以重叠。
超类型包含一个嵌套表'成员资格'。
当我创建子类型表时,似乎我必须再次重复NESTED TABLE语句,否则我将收到错误消息:
SQL错误:ORA-22913:必须为嵌套表列或属性
指定表名我有两个问题:
CREATE TYPE membership_type AS OBJECT
(membership_number INT,
membership_name VARCHAR2(20),
membership_date DATE)
CREATE TYPE membership_table AS TABLE OF membership_type
CREATE TYPE person_type AS OBJECT
(name VARCHAR2(100),
membership membership_table) NOT FINAL
CREATE TABLE person_table OF person_type
OBJECT ID SYSTEM GENERATED
NESTED TABLE membership
STORE AS person_membership
CREATE TYPE group1_type under person_type
(extraAttribute1 VARCHAR2(10))
CREATE TABLE group1_table OF group1_type
NESTED TABLE membership
STORE AS group1_membership --Is the way that I nested the membership table correct?
CREATE TYPE group2_type UNDER person_type
(extraAttribute2 VARCHAR2(50))
CREATE TABLE group2_table OF group2_type
NESTED TABLE membership
STORE AS group2_membership --Is the way that I nested the membership table correct?
INSERT INTO person_table VALUES
('person name',
membership_table(membership_type('123', 'membership name', '01-Aug-2016')));
INSERT INTO group1_table VALUES...
--can I refer to the supertype instead of duplicating the common value here?