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

MYSQL
资深网管教你一步步安装MYSQL数据库
在MySql中添加远程超级用户
如何实现MySQL表数据随机读取
MySQL多表操作和备份处理
教你编写高性能的mysql语法
mysql的字符串函数
MySQL 4.1 字符集支持的原理
数据库连接过多的错误,可能的原因分析及解决办法
mysql中的数据编码
MySQL 4.1x 中文乱码问题
从SQL server数据库导入Mysql数据库的体验
PEAR MDB 数据库抽象层 : 一次编写—随处运行
安装并使用phpMyAdmin管理MySQL数据库
解决phpMyAdmin2.6以上版本数据乱码问题
用ISAPI_Rewrite实现反向代理(ReverseProxy)
Mysql 数据库的导入与导出
如何使用MYSQL数据库进行备份数据恢复
MySQL数据库的多表操作和备份处理
一个简便的MySql数据库备份的方法
MySQL安全的二十三条军规

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


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