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