mysql創(chuàng)建Bitmap_Join_Indexes中的約束與索引
更新時(shí)間:2008年04月07日 20:41:03 作者:
現(xiàn)象:創(chuàng)建Bitmap Join Indexes時(shí)出現(xiàn)ORA-25954報(bào)錯(cuò): 維的主鍵或唯一約束條件缺失。 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);
創(chuàng)建:
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;
報(bào)錯(cuò)如下:
第 3 行出現(xiàn)錯(cuò)誤:
ORA-25954: 維的主鍵或唯一約束條件缺失
案例分析:在此處盡管定義了對表customers的唯一性索引,但是該索引并沒有對表customers并沒有唯一性約束,即表示唯一性索引并不表示對表進(jìn)行唯一性約束;但是如果加了唯一性的約束,就不會(huì)出現(xiàn)報(bào)錯(cuò),示例如下:
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;
索引已創(chuàng)建。
結(jié)論:
只要加了唯一性的約束,創(chuàng)建BJI則不會(huì)報(bào)錯(cuò)。
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);
創(chuàng)建:
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;
報(bào)錯(cuò)如下:
第 3 行出現(xiàn)錯(cuò)誤:
ORA-25954: 維的主鍵或唯一約束條件缺失
案例分析:在此處盡管定義了對表customers的唯一性索引,但是該索引并沒有對表customers并沒有唯一性約束,即表示唯一性索引并不表示對表進(jìn)行唯一性約束;但是如果加了唯一性的約束,就不會(huì)出現(xiàn)報(bào)錯(cuò),示例如下:
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;
索引已創(chuàng)建。
結(jié)論:
只要加了唯一性的約束,創(chuàng)建BJI則不會(huì)報(bào)錯(cuò)。
相關(guān)文章
MySQL 配置免密碼登錄的問題記錄(mysql_config_editor Configurati
這篇文章主要介紹了MySQL 配置免密碼登錄的問題記錄(mysql_config_editor Configuration),本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-08-08
Mysql如何解決1251 client does not support問題
這篇文章主要介紹了Mysql如何解決1251 client does not support問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09
基于MySQL數(shù)據(jù)庫復(fù)制Master-Slave架構(gòu)的分析
本篇文章是對MySQL數(shù)據(jù)庫復(fù)制Master-Slave架構(gòu)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
輕松上手MYSQL之SQL優(yōu)化之Explain詳解
Explain是SQL分析工具中非常重要的一個(gè)功能,它可以模擬優(yōu)化器執(zhí)行查詢語句,幫助我們理解查詢是如何執(zhí)行的,這篇文章主要給大家介紹了關(guān)于輕松上手MYSQL之SQL優(yōu)化之Explain詳解的相關(guān)資料,需要的朋友可以參考下2024-06-06
在OneProxy的基礎(chǔ)上實(shí)行MySQL讀寫分離與負(fù)載均衡
基于Libevent機(jī)制實(shí)現(xiàn),單個(gè)實(shí)例可以實(shí)現(xiàn)25萬的SQL轉(zhuǎn)發(fā)能力,用一個(gè)OneProxy節(jié)點(diǎn)可以帶動(dòng)整個(gè)MySQL集群,為業(yè)務(wù)發(fā)展貢獻(xiàn)一份力量,下面由小編來為大家簡單說說2019-05-05

