欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Oracle 在 Drop 表时的 Cascade Constraints

程序员文章站 2024-02-20 10:45:58
...

Oracle 在 Drop 表时的 Cascade Constraints

在 Oracle 使用 Drop 语句时,例如:

drop table CUSTOMER_INFO cascade constraints;

在删除主键约束时:

  • 使用 cascade 关键字,可以删除参照该列的那些外键和使用 on delete cascade 关键字来级联删除参照该关键字的数据。

  • 使用 cascade constraint 在删除列的同时删除约束。例如主键约束等等。

  • 使用 Drop table table_a cascade constraints 可以以删除关联 table table_a 的 constraint 来达成你 drop table table_a 的目的,原来属于表 table_b 的 foreign key constraint 已经跟随着被删除掉了,但是,储存在 table table_b 的资料可不会被删除,也就是说 Drop table cascade constraints 是不影响到存储于objec 里的 row data。

总的来说,对于那些处于包含了多个列的约束中的列的删除,我们一定要使用 cascade constraint 关键字,否则没有必要,虽然使用了也是没有错误的。