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

MYSQL
MYSQL教程:explain使用介绍
解析MYSQL授权原则
如何应对锁住的数据记录:NOLOCK和READPAST
甲骨文向MySQL用户开发者客户做出十项承诺
MYSQL教程:MySQL Show命令
使用MyISAM表和InnoDB的一些记录
找到MySQL的优点
MySQL下将一个表的数据插入到另外一个表的实现语句
mySQL 延迟 查询主表
SQL 语句优化方法30例
mysql 编码设置命令
Mysql5 字符集编码问题解决
MySQL 转义字符使用说明
通过HSODBC访问mysql的实现步骤
两个MySql服务的应用
mysql 备份与迁移 数据同步方法
3步搞定纯真IP数据导入到MySQL的方法详解
MySQL 错误处理例子[译]
mysql 日期和时间格式转换实现语句
MySQL 数据类型 详解

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


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