Oracle建立索引政策
學習 Oracle時,經常會遇到 Oracle索引問題,這裡将介紹Oracle索引問題的解決方法。Oracle索引和對應的表應該位于不同的表空間中,Oracle能夠并行讀取位于不同硬碟上的資料,可以避免産生I/O沖突B樹索引:在B樹的葉節點中 存儲索引字段的值與ROWID.唯一索引和不唯一索引都隻是針對B樹索引而言。Oracle最多允許包含32個字段的複合索引
Oracle索引建立政策
1.導入資料後再建立索引
2.不需要為很小的表建立索引
3.對于取值範圍很小的字段(比如性别字段)應當建立位圖索引
4.限制表中的索引的數目
5.為索引設定合适的PCTFREE值
6. 存儲索引的表空間最好單獨設定
建立不唯一索引
1. create index emp_ename on employees(ename)
2. tablespace users
3. storage(……)
4. pctfree 0;
建立唯一索引
1. create unique index emp_email on employees(email)
2. tablespace users;
建立位圖索引
1. create bitmap index emp_sex on employees(sex)
2. tablespace users;
建立反序索引
1. create unique index order_reinx on orders(order_num,order_date)
2. tablespace users
3. reverse;
建立函數索引(函數索引即可以是普通的B樹索引,也可以是位圖索引)
1. create index emp_substr_empno
2. on employees(substr(empno,1,2))
3. tablespace users;
以上介紹Oracle索引建立政策。