• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Oracle 10g中unique与index的问题

mysql 搞代码 4年前 (2022-01-09) 13次浏览 已收录 0个评论

Oracle 10g中unique与index的问题 create table test ( x integer, y integer, z integer ); alter table test add constr

Oracle 10g中unique与index的问题

create table test

(

x integer,

y integer,

z integer

);

alter table test add constraint primary key (x); –产生一个约束,并产生一个同名索引

create uni本文来源gao($daima.com搞@代@#码8网^que index index01 on test(x,y);

–create unique index index02 on test(x,y); –不允许完全相同的索引,即使索引名称不同

create unique index index03 on test(y,z);

create unique index index04 on test(z,y); –index04 是与index03互不相同的索引

alter table test add constraint cons01 unique(x,y,z) ; –产生一个约束,并自动产生一个名为cons01 的UNIQUE索引

alter table test add constraint cons01 unique(x,y) ; –产生一个约束,但因与index01 重复(自动产生的索引不区分顺序),因此不能自动产生索引

alter table test add constraint cons01 unique(y,x) ; –产生一个约束,但因与index01 重复,因此不能自动产生索引

–create unique index cons01 on test(x,y); –不能执行,因为索引cons01 已经被约束cons01 自动创建的索引占用

alter table test add constraint cons012 check (x>100);
alter table test add constraint cons013 check (x>100); –check可以内容完全相同

处理办法:

提取所有约束(UCPR)

提取名称不在约束表中的所有索引

本文永久更新链接地址:


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Oracle 10g中unique与index的问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址