052-168

You execute this command to drop the ITEM table, which has the primary key referred in the ORDER
table:
SQL> DROP TABLE scott.item CASCADE CONSTRAINTS PURGE;
Which two statements are true about the effect of the command? (Choose two.)
A.No flashback is possible to bring back the ITEM table.
B.The ORDER table is dropped along with the ITEM table.
C.The dependent referential integrity constraints in the ORDER table are disabled.
D.The dependent referential integrity constraints in the ORDER table are removed.
E.The table definition of the ITEM table and associated indexes are placed in the recycle bin.

由于使用了 PURGE,不会将表和相关的对象放入回收站,因此 flashback 不能用,A 对,E 错
指定 CASCADE CONSTRAINTS 语句是指删除所有的参照完整性约束包括主键约束和唯一性约束。
如果不指定此语句,则参照完整性约束还存在,drop table 时会返回一个错误。 C 错,D 对
B 错误,如果想实现这个需要级联删除,
alter table order_status2 add constraint order_status2_modified_by_fk modified_by references
employees(employee_id) on delete cascade;
--使用了 on delete cascade 语句,用于删除父表一条记录的时候,子表记录也要删除
alter table order_status2 add constraint order_status2_modified_by_fk modified_by references
employees(employee_id) on delete set null;
--这里使用了 on delete set null 语句,当父表删除的时候,子表记录就会设置为空

原文地址:https://www.cnblogs.com/Babylon/p/8039202.html