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

MYSQL
MySQL查询优化
优化MySQL数据库查询的三种方法
MySQL优化之数据类型的使用
建立MySQL数据库日常维护规范
MySQL数据库性能优化妙招
如何修复MySQL数据库表
MySQL数据库之UPDATE更新语句精解
分步启动数据库以重命名数据文件
使用实例管理器轻松管理多个MySQL实例
认识MySQL数据库对服务器端光标的限制
菜鸟课堂:玩转MySQL数据库 性能优化八法
深入浅出MySQL双向复制技术
MySQL百万级高并发网站实战攻略
5招优化MySQL插入方法
MySQL 集群配置
SQL Server数据库备份出错及应对措施
mysql3升级到mysql5解决乱码心得
数据库基础:MySQL 添加用户的两种方法
浅谈MySQL存储引擎选择 InnoDB还是MyISAM
数据库安全应用 使用MySQL的23个注意事项

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 102 ::
收藏到网摘: 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则不会报错。