列不为空可延迟
在 Oracle 中,延迟约束仅在提交时检查。
在 NOT NULL 约束的情况下 DEFERRABLE 子句的含义是什么? 例如,
create table test(a number not null deferrable, b number);
insert into test(a,b) values (222, 111);
commit;
在这些语句之后,我认为以下代码可以工作
update test set a = null where b = 111;
delete test where b = 111;
commit;
,但事实并非如此。
两个定义有什么区别?
create table test1(a number not null deferrable, b number);
create table test2(a number not null, b number);
In Oracle deferred constraints are checked only at the point of commit.
What is the meaning of DEFERRABLE clause in a case of NOT NULL constraint?
For example
create table test(a number not null deferrable, b number);
insert into test(a,b) values (222, 111);
commit;
After these statements I thought the following code would work
update test set a = null where b = 111;
delete test where b = 111;
commit;
But it doesn't.
What is the difference between two definitions?
create table test1(a number not null deferrable, b number);
create table test2(a number not null, b number);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有两个选择。您需要使用下面所示的命令在事务中设置要延迟的约束。
这应该在执行您定义的
UPDATE
语句之前运行。或者,您可以在表定义中将约束设置为 INITIALLY DEFERRED
完成上述任一操作后,您应该能够运行问题中的 DML。
There are two options here. Either you need to set the constraint to be deferred within the transaction by using the command shown below
This should be run before doing the
UPDATE
statement that you have defined.Alternatively you can set the constraint to be
INITIALLY DEFERRED
in the table definitionAfter doing either of these things, you should then be able to run the DML that you have in the question.