最初的問題是隻是一個名稱不匹配,這是錯誤信息真的說的;行和位置指向單詞relates
,ORA-00904告訴您它無效。您的property_t
類型定義爲relatesTo ref appointment_t
,但在您的property_table
創建中,請參閱relates
,而不是relatesTo
。
但是,你似乎有一個類型不匹配。 appointment_t
是一個對象類型,不是表類型,所以嵌套表子句沒有意義;你會得到ORA-22912: specified column or attribute is not a nested table type
。您似乎將某種對象類型與表格類型混淆在一起。
目前還不清楚您是希望將其作爲單個對象類型的參考,還是約會表(或參考約會) - 我認爲表可能更可能,正如您所期望的不同的視角爲出售物業,在這種情況下,你需要一個額外的類型,預約表(?):
create or replace type appointment_tab_t as table of appointment_t
/
...或者因爲你的原本有一個裁判預約單,如預約參考表格:
create or replace type appointment_tab_t as table of ref appointment_t
/
無論哪種方式你的property_t
類型將有:
..., relatesTo appointment_tab_t)
...那麼你的表格將與創建:
Create table property_table of property_t(
property# Primary Key)
Nested table relatesTo store as relates_appoint_table;
Table property_table created.
SQL Fiddle demo(或with table of ref
)用一個虛構的預約類型。
的選擇是離開property_t
因爲你擁有了它與裁判預約單:
..., relatesTo ref appointment_t)
...拖放嵌套表子句:
Create table property_table of property_t(
property# Primary Key)
/
Table property_table created.
SQL Fiddle。
你可以發佈你正在使用的實際代碼嗎?以上是無效的DDL。 – mmmmmpie 2015-02-10 13:39:58
肯定是一個散列標記'#'在SQL中無效,是嗎? – 2015-02-10 13:40:38
嗨,這是我們正在使用的實際代碼,並且已經用於以前的表創建, – 2015-02-10 13:41:11