Oracle 12C -- truncate的级联操作
生活随笔
收集整理的這篇文章主要介紹了
Oracle 12C -- truncate的级联操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在之前的版本中,存在外鍵約束時,無法直接truncate父表。在12C中,對truncate操作添加了級聯操作特性。
前提是創建外鍵約束時,使用了"on delete casacde"。
?
測試腳本:
SQL> drop table child; SQL> drop table parent; SQL> create table parent(id number primary key); SQL> create table child(cid number primary key,pid number); SQL> alter table child add constraint fk_parent_child foreign key(pid) references parent(id) on delete cascade; SQL> insert into parent values(1); SQL> insert into parent values(2); SQL> insert into child values(1,1); SQL> insert into child values(2,1); SQL> insert into child values(3,2); SQL> commit; SQL> select a.id,b.cid,b.pid from parent a, child b where a.id=b.pid;ID CID PID ---------- ---------- ----------1 1 11 2 12 3 2SQL>
11gR2的測試結果:
12C的測試結果:
SQL> truncate table parent cascade;Table truncated.SQL>?
轉載于:https://www.cnblogs.com/abclife/p/4720152.html
總結
以上是生活随笔為你收集整理的Oracle 12C -- truncate的级联操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java注解简单实例
- 下一篇: 新写的c++日志库:log4K