未强制执行唯一约束检查
create table A (id, field1, field2, field3, field4)
我对 field1、field2、field3 有一个唯一约束
,并且以下记录存储在表中,
例如
insert into A (1, "f1", null, "f3", "f4");
insert into A (2, "f1", null, "f3", "f4");
insert into A (3, "f1", null, "f3", "f4");
我希望这会引发唯一的约束违规,因为所有记录都违反了,但事实并非如此。我在这里缺少什么,检查了数据库并且已经创建了唯一约束索引。
create table A (id, field1, field2, field3, field4)
I have a unique constraint on field1, field2, field3
and the following records are stored in the table
e.g.
insert into A (1, "f1", null, "f3", "f4");
insert into A (2, "f1", null, "f3", "f4");
insert into A (3, "f1", null, "f3", "f4");
I would expect this to throw an unique constraint violation since all records are in violation, but it doesn't. What am I missing here, did check the database and the unique constraint index has been created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Null
值永远不会等于任何其他值,甚至null
也是如此。null != null
这就是为什么记录
a + null + b
永远不会重复记录a + null + b
Null
value is never equal to any other value, evennull
too.null != null
That is why record
a + null + b
will be never duplicate recorda + null + b