数据库 
首页 > 数据库 > 浏览文章

mysql创建Bitmap_Join_Indexes中的约束与索引

(编辑:jimmy 日期: 2024/9/21 浏览:3 次 )
测试过程如下:
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则不会报错。 
上一篇:提高MySQL 查询效率的三个技巧第1/2页
下一篇:MySQL取出随机数据
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap