我有一张约有3,00,000条记录的表格,例如
CREATE TABLE xxx
( xxx_PK NUMBER(10,0),
CREATEDTIME TIMESTAMP (6),
MODIFIEDTIME TIMESTAMP (6),
CREATOR NUMBER(10,0),
LASTMODIFIER_FK NUMBER(10,0),
a_FK NUMBER(10,0),
b_FK NUMBER(10,0),
c_FK NUMBER(10,0),
d_FK NUMBER(10,0),
e_FK NUMBER(10,0),
f NUMBER(10,0),
PRIMARY KEY (xxx_PK),
CONSTRAINT FOREIGN KEY (LASTMODIFIER_FK)
REFERENCES USERS (USERID_PK) ENABLE NOVALIDATE,
CONSTRAINT FOREIGN KEY (a_FK)
REFERENCES a (a_PK) ENABLE NOVALIDATE,
CONSTRAINT FOREIGN KEY (b_FK)
REFERENCES b (b_PK) ENABLE NOVALIDATE,
CONSTRAINT FOREIGN KEY (c_FK)
REFERENCES c (c_PK) ENABLE NOVALIDATE,
CONSTRAINT FOREIGN KEY (d_FK)
REFERENCES d (d_PK) ENABLE NOVALIDATE,
CONSTRAINT FOREIGN KEY (e_FK)
REFERENCES e (e_PK) ENABLE NOVALIDATE
);
CREATE INDEX f_INDEX ON xxx (f) ;
当我试图截断时,收到错误 -
ora 02266
02266, 00000, "unique/primary keys in table referenced by enabled foreign keys"
*Cause: An attempt was made to truncate a table with unique or
primary keys referenced by foreign keys enabled in another table.
Other operations not allowed are dropping/truncating a partition of a
partitioned table or an ALTER TABLE EXCHANGE PARTITION.
*Action: Before performing the above operations the table, disable the
foreign key constraints in other tables. You can see what
constraints are referencing a table by issuing the following
command:
SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";
我们还提供yyy和zzz,其中包含表xxx的引用。表yyy和zzz是空的。
编辑 - 当我禁用他的子表yyy和zzz的约束时,它被成功截断。
请建议我该怎么做。