广

MYSQL

  • MYSQL
  • MSSQL
  • Redis
  • MongoDB
  • oracle数据库
  • 数据管理

    mysql创建Bitmap_Join_Indexes中的约束与索引

    2018-05-08 11:29:27 次阅读 稿源:互联网
    零七网广告
    全网推广平台,软文发布
    测试过程如下:
    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则不会报错。 

    零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。

    零七网广告
    零七网广告
    零七网广告
    零七网广告