ORA-22912指定的列或属性不是嵌套表类型/ oracle创建嵌套表

时间:2013-05-28 06:56:55

标签: oracle oracle11g nested-table

我正在与OODB合作并尝试使用两个表创建一个嵌套表。我在这里发布代码

create type BranchType as object(
address AddrType,
phone1 integer,
phone2 integer );

create table BranchTableType of BranchType;

create type PublisherType as object(
name varchar2(50),    
addr AddrType,
branches BranchType);

代码打算按分支类型创建一个表分支,然后创建一个类型Publisher类型,然后尝试创建一个嵌套表。

create table Publishers of PublisherType NESTED TABLE
branches STORE as branchTable

但是上面的代码给出了错误,指出指定的类型不是嵌套的表类型。请帮帮我。

1 个答案:

答案 0 :(得分:0)

您似乎在对象,对象表和对象表之间混合类型。这构建了addrtype,因为问题中未对此进行描述:

create type addrtype as object(
city varchar2(20)
)
/

create type BranchType as object(
address AddrType,
phone1 integer,
phone2 integer )
/

create type BranchTableType as table of BranchType
/

create type PublisherType as object(
name varchar2(50),    
addr AddrType,
branches BranchTableType)
/

create table Publishers of PublisherType NESTED TABLE
branches STORE as branchTableTypeStore
/

SQL Fiddle

主要区别是:

create type BranchTableType as table of BranchType

表格类型而不是表格,而不是:

create table BranchTableType of BranchType;

create type PublisherType as object(
...
branches BranchTableType)

使用嵌套表类型,而不是:

create type PublisherType as object(
...
branches BranchType);

branches STORE as branchTableTypeStore

作为存储名称而不是类型,而不是:

branches STORE as branchTable

但我不完全确定你会做什么,如果这正是你想要的。希望无论如何这将指向正确的方向......