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