在唯一的索引甲骨文上启用Novalidate
在Oracle中,我想将此独特的约束添加到表格,并带有一些记录,这些记录与此独特的约束相关。为了在表中添加此独特的约束而没有验证表格上的先前数据,我在语句结束时启用了NovAlidate,但是它有一个错误:
ORA-02158: invalid CREATE INDEX option
有什么方法可以在表中添加此唯一索引而不验证表格中的先前记录?
create unique index UK_SAME_THREAD ON T_THREADPARTICIPANT
(case when C_OPPOSITE_USER_ID is not null then C_OPPOSITE_USER_ID else null end,
case when C_OPPOSITE_USER_ID is not null then F_PARTICIPANT else null end,
case when C_OPPOSITE_USER_ID is not null then C_CONTACT_TYPE else null end)
ENABLE NOVALIDATE;
In oracle, I want to add this unique constraint to a table with some records that contracted this unique constraint. for adding this unique constraint without validating previous data on the table I added ENABLE NOVALIDATE at the end of the statement but it has an error:
ORA-02158: invalid CREATE INDEX option
Is there any way to add this unique index without validating previous records in Table?
create unique index UK_SAME_THREAD ON T_THREADPARTICIPANT
(case when C_OPPOSITE_USER_ID is not null then C_OPPOSITE_USER_ID else null end,
case when C_OPPOSITE_USER_ID is not null then F_PARTICIPANT else null end,
case when C_OPPOSITE_USER_ID is not null then C_CONTACT_TYPE else null end)
ENABLE NOVALIDATE;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方法是 a)创建索引(非唯一), b)创建不验证现有值的独特约束。
包含重复ID值的表:
这是您尝试执行的操作:
让我们只
Alter Table
并添加唯一约束(这也不起作用):So:创建索引 首先...
...和更改表接下来:
它可以使用吗?
我想是的。
Workaround is to a) create index (non-unique), b) create unique constraint that doesn't validate existing values.
Table that contains duplicate ID values:
This is what you tried to do:
Let's just
alter table
and add unique constraint (that won't work either):So: create index first ...
... and alter the table next:
Does it work?
I guess it does.