《Mysql必讀mysql創(chuàng)建Bitmap_Join_Indexes中的約束與索引》要點:
本文介紹了Mysql必讀mysql創(chuàng)建Bitmap_Join_Indexes中的約束與索引,希望對您有用。如果有疑問,可以聯(lián)系我們。
測試過程如下:
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;?
報錯如下:?
第?3?行出現(xiàn)錯誤:?
ORA-25954:?維的主鍵或唯一約束條件缺失
案例分析:在此處盡管定義了對表customers的唯一性索引,但是該索引并沒有對表customers并沒有唯一性約束,即表示唯一性索引并不表示對表進行唯一性約束;但是如果加了唯一性的約束,就不會出現(xiàn)報錯,示例如下:
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則不會報錯.?
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/3507.html