zoukankan      html  css  js  c++  java
  • SQL:deferrable initially deferred

    SQL> create table cust(id number,name varchar2(10));
    Table created

    SQL> alter table cust add constraint cust_id_pk primary key(id) deferrable initially deferred;--延缓约束
    Table altered

    SQL> insert into cust values(1,'raj');
    1 row inserted

    SQL> insert into cust values(1,'sam');
    1 row inserted

    SQL> commit; --只有在提交的时候才会使用约束条件
    commit
    ORA-02091: 事务处理已回退
    ORA-00001: 违反唯一约束条件 (OE.CUST_ID_PK)

    SQL> select * from cust;  --提交时违反约束条件则全部回退。
    ID NAME
    ---------- ----------

    SQL> set constraint cust_id_pk immediate;  --修改约束为立即模式,即插入数据时立即使用约束条件
    Constraints set

    SQL> insert into cust values(1,'lata');
    1 row inserted

    SQL> insert into cust values(2,'king');
    1 row inserted

    SQL> insert into cust values(2,'test');
    insert into cust values(2,'test')
    ORA-00001: 违反唯一约束条件 (OE.CUST_ID_PK)

    SQL> commit;
    Commit complete

    SQL> select * from cust;
    ID NAME
    ---------- ----------
    1 lata
    2 king

    SQL>

  • 相关阅读:
    求全排列,调用C++函数
    ZOJ 3508 (the war)
    HDU 1285
    SDUT--枚举(删数问题)
    SDUT--进制转换
    位运算
    [NOI2015]软件包管理器
    列队[noip2017]
    [APIO2007]动物园
    [NOI2001]炮兵阵地
  • 原文地址:https://www.cnblogs.com/rusking/p/4599414.html
Copyright © 2011-2022 走看看