Ole*_*liv 6 oracle data-integrity
在Oracle中,仅在提交时检查延迟约束.
在NOT NULL约束的情况下,DEFERRABLE子句的含义是什么?例如
create table test(a number not null deferrable, b number);
insert into test(a,b) values (222, 111);
commit;
Run Code Online (Sandbox Code Playgroud)
在这些陈述后,我认为以下代码将起作用
update test set a = null where b = 111;
delete test where b = 111;
commit;
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.
两个定义有什么区别?
create table test1(a number not null deferrable, b number);
create table test2(a number not null, b number);
Run Code Online (Sandbox Code Playgroud)
Mik*_*ers 10
这里有两个选择.您需要使用下面显示的命令将约束设置为在事务中延迟
SET CONSTRAINTS ALL DEFERRED;
Run Code Online (Sandbox Code Playgroud)
这应该在执行UPDATE您定义的语句之前运行.
或者,您可以将约束设置INITIALLY DEFERRED为表定义
create table test(a number not null initially deferred deferrable, b number);
Run Code Online (Sandbox Code Playgroud)
完成其中任何一项后,您应该能够运行问题中的DML.
| 归档时间: |
|
| 查看次数: |
3867 次 |
| 最近记录: |