当前位置: 首页 > 图文教程 > 数据库 > MYSQL > mysql创建Bitmap_Join_Indexes中的约束与索引

MYSQL
教你如何编写高效的MySQL数据库应用
解析MySQL数据库是如何对抗解密高手
MySQL常见问题集锦解答及技巧
透视MySQL数据库之更新语句
MYSQL的操作类(已封装)
windows环境下mysql数据库的主从同步备份步骤
优化MySQL数据库性能的八大“妙手”
安装与卸载MySQL系统服务(常见问题)
在SQL Server中快速删除重复记录
教你用Myisamchk进行崩溃恢复MySQL
再谈MySQL数据库备份恢复和乱码问题
一个MySQL数据备份/恢复的简易方法
教你如何将MySQL数据库的密码恢复
MySQL数据库中双机热备配置份过程
关于MySQL数据库基本调度策略的简介
让MySQL数据库自动恢复的具体操作
MySQL加强对PHP的支持--mysqlnd_php6
MYSQL初学者使用指南(下篇)
MYSQL初学者使用指南(上篇)
mysql中的替换语句

MYSQL 中的 mysql创建Bitmap_Join_Indexes中的约束与索引


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 92 ::
收藏到网摘: n/a

现象:创建Bitmap Join Indexes时出现ORA-25954报错: 维的主键或唯一约束条件缺失。 53vi.Com 原因:受到约束与索引的影响。 测试过程如下:
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则不会报错。