下面是我创建的表。
CREATE TYPE ft_obj AS OBJECT (
ftid NUMBER(5),
ftlocation VARCHAR(30),
country VARCHAR(10)
);
/
CREATE TABLE ft_table OF ft_obj (
ftid PRIMARY KEY
) OBJECT IDENTIFIER IS PRIMARY KEY;
/
CREATE TYPE frod_obj AS OBJECT (
prodid NUMBER(6),
ft_ref ft_obj,
proddesc VARCHAR(50),
costperitem DECIMAL,
labcostperitem DECIMAL
);
/
CREATE TABLE frod_table OF frod_obj (
prodid PRIMARY KEY
) OBJECT IDENTIFIER IS PRIMARY KEY;
CREATE TYPE wf_obj AS OBJECT (
wfid NUMBER,
ft_ref ft_obj,
wfname VARCHAR(30),
taxcode INT,
yearlyincome DECIMAL,
yearlytax DECIMAL
);
/
CREATE TABLE wf_table OF wf_obj (
wfid PRIMARY KEY
) OBJECT IDENTIFIER IS PRIMARY KEY;
/
CREATE TYPE wfusage_obj AS OBJECT (
jobdate DATE,
jobhours INT,
jobhourlyrate DECIMAL,
jobposted CHAR,
wfid_ref REF wf_obj
);
/
CREATE TYPE wfusage_nesttabtyp AS
TABLE OF wfusage_obj;
/
CREATE TABLE wfusage_objtab OF wfusage_obj;
/
CREATE TYPE odetails_obj AS OBJECT (
mfid NUMBER,
prodid_ref REF frod_obj,
quantity INT,
itemprice DECIMAL,
wfusage_ntab wfusage_nesttabtyp
);
/
CREATE TYPE odetails_nesttabtyp AS
TABLE OF odetails_obj;
/
CREATE TYPE prod_obj AS OBJECT (
prodoid NUMBER,
odate DATE,
promisedate DATE,
completiondate DATE,
shipmentdate DATE,
status VARCHAR(20),
odetails_ntab odetails_nesttabtyp
);
/
CREATE TABLE prod_objtab OF prod_obj (
PRIMARY KEY ( prodoid )
) OBJECT IDENTIFIER IS PRIMARY KEY
NESTED TABLE odetails_ntab STORE AS oprod_ntab ( (
PRIMARY KEY ( nested_table_id,
mfid )
)
ORGANIZATION INDEX
COMPRESS ) RETURN AS LOCATOR
/
ALTER TABLE oprod_ntab ADD (
SCOPE FOR ( prodid_ref ) IS frod_table
);
/
在创建嵌套表时出现以下错误。
ORA-02320:无法为嵌套表列创建存储表 odetails_ntab ORA-25175:找不到主键约束 02320。00000-“为嵌套表列%s创建存储表失败” *原因:在创建存储表时发生错误 指定的嵌套表列。 *操作:请参阅以下消息以了解更多详细信息。如果情况 他们描述可以纠正,可以这样做;否则联系Oracle 支持。
INSERT INTO prod_objtab VALUES ( 45000,
'12-April-2019',
'01-MAy-2019',
'01-MAy-2019',
'01-MAy-2019',
'COMPLETED',
odetails_nesttabtyp()
);
INSERT INTO TABLE (SELECT pr.odetails_ntab FROM prod_objtab pr WHERE pr.prodorderid = 45000 )
values (45001,(SELECT REF(pt) FROM frod_table pt WHERE pt.prodid = 10001 ),100,500,
wfusage_nesttabtyp(wfusage_obj('12-April-2019',60,100,'AME',
(SELECT REF(wf) FROM wf_table wf WHERE wf.wfid = 240))));
在第9行中获取错误 ORA-01401:插入值对于列而言太大
答案 0 :(得分:1)
ORA-02320:无法为嵌套表列创建存储表 odetails_ntab ORA-25175:找不到主键约束02320。00000 -“为嵌套表列%s创建存储表失败” *原因:为指定的嵌套表列创建存储表时发生错误。 *操作:查看随后的消息 更多细节。如果他们描述的情况可以纠正,请执行 所以;否则,请联系Oracle支持。
自完成Multi-level
嵌套以来,在创建表时,Storage
表也需要两个级别的Nested
。参见下面的操作方法。
CREATE TABLE prod_objtab OF prod_obj (
PRIMARY KEY ( prodoid )
) OBJECT IDENTIFIER IS PRIMARY KEY
NESTED TABLE odetails_ntab STORE AS oprod_ntab ( ( PRIMARY KEY (NESTED_TABLE_ID, mfid ))
ORGANIZATION INDEX COMPRESS
NESTED TABLE wfusage_ntab STORE AS XX ) RETURN AS LOCATOR;