我的sales_person_type定义如下:
CREATE OR REPLACE TYPE sales_person_type UNDER person_type (
salesAppointments sales_person_appointments
);
这是person_type的子类,定义如下:
CREATE OR REPLACE TYPE person_type AS OBJECT (
personID NUMBER,
forename VARCHAR2(30),
surname VARCHAR2(20),
dateOfBirth DATE
) NOT FINAL;
我试图创建一个销售人员表并将主键指定为超类属性,如下所示:
CREATE TABLE sales_person_table OF sales_person_type (
PRIMARY KEY (personID),
OBJECT IDENTIFIER IS PRIMARY KEY)
NESTED TABLE salesAppointments STORE AS sale_appointment_table (
(PRIMARY KEY(NESTED_TABLE_ID, appointmentID))
ORGANIZATION INDEX COMPRESS)
RETURN AS LOCATOR
但是我收到了这个错误:
SQL错误:ORA-02330:不允许使用数据类型规范 02330. 00000 - "数据类型规范不允许" *原因:尝试在列中指定数据类型 对象表的约束规范。
我认为这是因为我试图将主键分配为超类属性?这是正确的语法吗?
干杯。
编辑:
立即行动,感谢Dimitry。
答案 0 :(得分:0)
检查CREATE TABLE for OID子句的语法:
SQL> CREATE OR REPLACE TYPE person_type AS OBJECT (
2 personID NUMBER,
3 forename VARCHAR2(30),
4 surname VARCHAR2(20),
5 dateOfBirth DATE
6 ) NOT FINAL;
7 /
SQL> create or replace type sale_appointment is object
2 (
3 appointmentID integer
4 );
5 /
Тип создан.
SQL> create type sales_person_appointments as table of sale_appointment;
2 /
SQL> CREATE OR REPLACE TYPE sales_person_type UNDER person_type (
2 salesAppointments sales_person_appointments
3 );
4 /
SQL> CREATE TABLE sales_person_table OF sales_person_type (
2 PRIMARY KEY (personID)
3 )
4 OBJECT IDENTIFIER IS PRIMARY KEY
5 NESTED TABLE salesAppointments STORE AS sale_appointment_table (
6 (PRIMARY KEY(NESTED_TABLE_ID, appointmentID))
7 ORGANIZATION INDEX COMPRESS)
8 RETURN AS LOCATOR
9 /
Table created.