0

我创建了customer_ty一个对象,其中包括一个名为“存款”的嵌套表。

CREATE TYPE deposit_ty as object(
depNo number,
depCategory ref depcategory_ty,
amount number,
period number
)
/

此“depCategory”引用另一个名为“depcategory_tbl”的表中的 depcategory_ty。

CREATE TYPE deposit_ntty as table of depcategory_ty
/

CREATE TYPE address_ty as varray(3) of varchar2(20)
/

CREATE TYPE customer_ty as object(
custId varchar2(4),
custName varchar2(10),
address address_ty,
dob date,
deposits deposit_ntty
)
/

CREATE TABLE customer_tbl of customer_ty(
custId primary key)
nested table deposits store as cli_deposit_tbl
/

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

当我尝试为表添加范围时出现问题。它说;

add scope for (depCategory) is depcategory_tbl
               *
ERROR at line 2:
ORA-0094:"DEPCATEGORY":Inavalid Identifier

所有标识符都是正确的。这有什么问题?

4

1 回答 1

2

看起来您的定义deposit_ntty不正确,并且意味着它是:

CREATE TYPE deposit_ntty as table of deposit_ty
/

有了这个改变,你的改变现在得到:

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

ORA-22892: scoped table "DEPCATEGORY_TBL" does not exist in schema "PUBLIC"

你可能已经有了,但没有显示出来;有了它,改变作品:

CREATE TABLE depcategory_tbl of depcategory_ty;

Table DEPCATEGORY_TBL created.

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

Table CLI_DEPOSIT_TBL altered.
于 2016-03-22T15:52:21.237 回答