我已經創建瞭如下的對象關係類型。帶對象類型的PL/SQL PRIMARY KEY
CREATE OR REPLACE TYPE familycar_t AS OBJECT (
make VARCHAR (10),
model VARCHAR(10),
year NUMBER (4),
fuel_type VARCHAR (10));
/
CREATE OR REPLACE TYPE sedan_t AS OBJECT (
familycar ref familycar_t,
cylinder_Size number(10));
/
CREATE TABLE familycar OF familycar_t (PRIMARY KEY (make,model));
現在我想爲「轎車」表設置主要如下。
CREATE TABLE sedan OF sedan_t (PRIMARY KEY (familycar_t.make,familycar_t.model));
但錯誤發生一樣,
Error starting at line : 4 in command - CREATE TABLE sedan OF sedan_t (PRIMARY KEY (familycar_t.make,familycar_t.model)) Error report - SQL Error: ORA-00904: "FAMILYCAR_T"."MAKE": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action:
什麼是它的解決方案嗎?
你有沒有試過:'主鍵(familycar.make,familycar.model)'?也就是說,引用對象,而不是類型。 –
我嘗試了下面的方法,但不正確... CREATE TABLE sedan OF sedan_t(PRIMARY KEY(make%familycar,model%familycar)); CREATE TABLE sedan OF sedan_t(PRIMARY KEY(familycar.make%familycar_t,familycar.model%familycar_t)); CREATE TABLE sedan OF sedan_t(PRIMARY KEY(familycar.make%familycar_t,familycar.model%familycar_t)); – Chamal