set constraints all deferred|immediate的作用
来源:互联网 发布:淘宝访问受限怎么回事 编辑:程序博客网 时间:2024/04/24 15:10
这个跟你添加约束的时候有关,约束有三个选项:
DEFERRABLE INITIALLY DEFERRED
DEFERRABLE INITIALLY IMMEDIATE
NOT DEFERRABLE
默认的话是第三种,而第三中是immediate的,并不受set constraint影响
例如:
以一般方式添加的约束
SQL> create table t1(a int);
Table created.
SQL> alter table t1 add constraint pk unique(a);
Table altered.
SQL> select deferrable from dba_constraints where owner='GOWIN' and constraint_n
ame='PK';
DEFERRABLE
--------------
NOT DEFERRABLE
SQL> create or replace procedure tes
2 as
3 begin
4 insert into t1 values (1);
5 insert into t1 values (1);
6 end;
7 /
Procedure created.
SQL> set constraints all deferred;
constraint set.
SQL> exec tes
BEGIN tes; END;
*
ERROR at line 1:
ORA-00001: unique constraint (GOWIN.PK) violated
ORA-06512: at "GOWIN.TES", line 5
ORA-06512: at line 1
然后以另两种方式中的一种添加约束的方式
SQL> drop table t1;
Table dropped.
SQL> create table t1(a int);
Table created.
SQL> alter table t1 add constraint pk unique(a) DEFERRABLE initially deferred;
Table altered.
SQL> select deferrable from dba_constraints where owner='GOWIN' and constraint_n
ame='PK';
DEFERRABLE
--------------
DEFERRABLE
SQL> create or replace procedure tes
2 as
3 begin
4 insert into t1 values (1);
5 insert into t1 values (1);
6 end;
7 /
Procedure created.
SQL> exec tes
PL/SQL procedure successfully completed.
SQL> select * from t1;
A
----------
1
1
SQL> commit;
commit
*
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-00001: unique constraint (GOWIN.PK) violated
- set constraints all deferred|immediate的作用
- SET CONSTRAINTS DEFERRED | IMMEDIATE
- OCP-047 SET CONSTRAINTS DEFERRABLE OR IMMEDIATE
- DEFERRED IMMEDIATE
- OCP-047约束延迟 SET CONSTRAINTS DEFERRABLE OR IMMEDIATE
- yum clean all的作用
- Makefile 中all:的作用
- set的作用
- SET ANSI_NULLS ON的作用
- SET NOCOUNT ON的作用
- SET ANSI_NULLS ON的作用
- get和set的作用
- makefile中的all和.PHONY的作用
- makefile中的all和.PHONY的作用
- makefile中的all和.PHONY的作用
- makefile中的all和.PHONY的作用
- makefile 中ALL 和 .PHONY的作用
- makefile中的all和.PHONY的作用
- "未将对象引用设置到对象的实例"异常的原因
- samba的配置-- 在vmware中和windows目录共享
- 鼠标消息
- SQL注入
- using JMX to Manage Web Applications (from tts)
- set constraints all deferred|immediate的作用
- 初试XSL
- 一年前的帖子,一年前的回忆(渐行渐远 2004)
- 可完全定制的Javascript日历 (Callback 实现)
- Eclipse基础--安装eclipse及语言包
- 隐藏在暗中的this指针
- 个人所得税计算器 源代码 及 程序
- C++事件的实现
- 使用XMLBeans处理XML数据和文档入门