创建Bitmap_Join_Indexes中的约束与索引

资讯 驱动中国 若水 253 次阅读 0 条评论
分享 Q
        现象:创建Bitmap Join Indexes时出现ORA-25954报错: 维的主键或唯一约束条件缺失。

原因:受到约束与索引的影响。

测试过程如下:

create table sales

as select * from sh.sales;

 

create table customers

as

select * from sh.customers;

create unique index CUST_ID_un on customers(CUST_ID);

 

创建:

Bitmap Join Indexes

create bitmap index sales_cust_gender_bjix

on sales(customers.cust_gender)

from sales,customers

where sales.cust_id=customers.cust_id;

报错如下:

第 3 行出现错误:

ORA-25954: 维的主键或唯一约束条件缺失

 

案例分析:在此处尽管定义了对表customers的唯一性索引,但是该索引并没有对表customers并没有唯一性约束,即表示唯一性索引并不表示对表进行唯一性约束;但是如果加了唯一性的约束,就不会出现报错,示例如下:

 

SQL> ALTER TABLE customers

2 MODIFY (cust_id CONSTRAINT customers_un unique);

表已更改。

 

SQL> create bitmap index sales_cust_gender_bjix

2 on sales(customers.cust_gender)

3 from sales,customers

4 where sales.cust_id=customers.cust_id;

索引已创建。

结论:

只要加了唯一性的约束,创建BJI则不会报错。

版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友