zoukankan      html  css  js  c++  java
  • 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          1
             1          2          1
             2          3          2
    
    SQL> 


    11gR2的测试结果:

    SQL> truncate table parent cascade;
    truncate table parent cascade
                          *
    ERROR at line 1:
    ORA-03291: Invalid truncate option - missing STORAGE keyword
    
    
    SQL>

    12C的测试结果:

    SQL> truncate table parent cascade;
    
    Table truncated.
    
    SQL>
  • 相关阅读:
    Rotation Kinematics
    离职 mark
    PnP 问题方程怎么列?
    DSO windowed optimization 代码 (4)
    Adjoint of SE(3)
    IMU 预积分推导
    DSO windowed optimization 代码 (3)
    DSO windowed optimization 代码 (2)
    OKVIS 代码框架
    DSO windowed optimization 代码 (1)
  • 原文地址:https://www.cnblogs.com/abclife/p/4720152.html
Copyright © 2011-2022 走看看