Oracle:嵌套 table 在一个类型中
Oracle : Nested table inside a type
我需要创建具有 O_BIEN 属性的 table。 O_BIEN 类型包含 T_HABITANT 类型的嵌套 table。
这是我的代码:
CREATE OR REPLACE TYPE O_HABITANT AS OBJECT (
estmajeur CHAR(1),
lien VARCHAR(10)
);
\
CREATE OR REPLACE TYPE T_HABITANT AS TABLE OF O_HABITANT;
\
CREATE OR REPLACE TYPE O_BIEN AS OBJECT (
surfacetotale NUMBER(3, 2),
nombrepices VARCHAR(2),
habitant T_HABITANT
);
\
CREATE TABLE FISC (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
bien O_BIEN
)NESTED TABLE bien STORE AS NST_BIEN;
我有以下错误:
ORA-22912: specified column or attribute is not a nested table type"
*Cause: The storage clause is specified for a column or attribute
that is not a nested table column or attribute.
*Action: Specify a valid nested table column or attribute.
那么,如何将 O_BIEN 的居民属性指定为嵌套的 table?
当我用别名指定完整的列名时,这对我有用:
create table fisc (id number primary key, bien o_bien)
nested table bien.habitant store as bien_habitant_store;
我需要创建具有 O_BIEN 属性的 table。 O_BIEN 类型包含 T_HABITANT 类型的嵌套 table。
这是我的代码:
CREATE OR REPLACE TYPE O_HABITANT AS OBJECT (
estmajeur CHAR(1),
lien VARCHAR(10)
);
\
CREATE OR REPLACE TYPE T_HABITANT AS TABLE OF O_HABITANT;
\
CREATE OR REPLACE TYPE O_BIEN AS OBJECT (
surfacetotale NUMBER(3, 2),
nombrepices VARCHAR(2),
habitant T_HABITANT
);
\
CREATE TABLE FISC (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
bien O_BIEN
)NESTED TABLE bien STORE AS NST_BIEN;
我有以下错误:
ORA-22912: specified column or attribute is not a nested table type" *Cause: The storage clause is specified for a column or attribute that is not a nested table column or attribute. *Action: Specify a valid nested table column or attribute.
那么,如何将 O_BIEN 的居民属性指定为嵌套的 table?
当我用别名指定完整的列名时,这对我有用:
create table fisc (id number primary key, bien o_bien)
nested table bien.habitant store as bien_habitant_store;