时间:2021-07-01 10:21:17 帮助过:3人阅读
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>
SQL:deferrable initially deferred
标签: