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>

最新文章

  1. 基于canvas的陈列订货的分析
  2. H5+微信支付报-1问题
  3. 使用Python来对MySQL数据库进行操作
  4. jquery去掉或者替换字符,设置指定options为selected状态
  5. Unity 优化
  6. Component migration documentation
  7. [PHP学习日志]简单Session的使用
  8. 找不到eth0,但能找到eth1的问题解决办法
  9. 【翻译】MVC Music Store 教程-概述(三)
  10. USB CCID协议和PC/SC标准
  11. BZOJ 2809: [Apio2012]dispatching( 平衡树 + 启发式合并 )
  12. UVa 129 困难的串
  13. Python把给定的列表转化成二叉树
  14. 【Jenkins】Jenkins权威指南英文版:jenkins-the-definitive-guide.pdf
  15. ES 16 - 对Elasticsearch中的索引数据进行增删改查 (CRUD)
  16. 跨域405(Method Not Allowed)问题
  17. How to configure Samba Server share on Debian 9 Stretch Linux
  18. NodeMCU学习(三) : 进入网络世界
  19. npm安装socket.io时报错的解决方法(npm WARN enoent ENOENT: no such file or directory, open '/usr/local/nodejs/bin/package.json')
  20. HTTP Cookie 详解

热门文章

  1. image即时上传
  2. contenteditable 属性
  3. (转)div+css 布局经验 - 最简单的 = 最不变形的(原创技巧)
  4. 6、统计solr目录索引信息
  5. Couchbase 使用方法
  6. hadoop集群中的日志文件
  7. Python一路走来 面向对象1
  8. Cut the sticks
  9. XPath <第四篇>
  10. 给Eclipse安装Google app engine插件