![](/img/trans.png)
[英]how can i make uniqueness in existing oracle sql table if all columns are nullable and also not creating unique index but i can add constraint
[英]How does SQL determine uniqueness for a multi column unique index
我有一个表格,其中包含递送路线中的地址序列,例如:
地址 ID | 路线编号 | 序列 |
---|---|---|
21 | 1 | 11 |
46 | 11 | 1 |
我在RouteId
和Sequence
上有一个联合唯一索引。 上表是否会违反这两个记录合并为111
或者索引是否足够聪明以实现这不是重复的?
唯一索引不会以您建议的方式连接两个值,它确保{RouteId,Sequence}
对是唯一的。
在您的示例中,这对是{1,11}
和{11,1}
是不同的,因此在索引中都是合法的。 如果您尝试添加 routeId =1 且 Sequence =11 的第三行,则会违反唯一索引
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.