概論Oracle索引創(chuàng)建策略
學(xué)習(xí)Oracle時(shí),經(jīng)常會(huì)遇到Oracle索引問題,這里將介紹Oracle索引問題的解決方法。Oracle索引和對(duì)應(yīng)的表應(yīng)該位于不同的表空間中,Oracle能夠并行讀取位于不同硬盤上的數(shù)據(jù),可以避免產(chǎn)生I/O沖突B樹索引:在B樹的葉節(jié)點(diǎn)中存儲(chǔ)索引字段的值與ROWID。唯一索引和不唯一索引都只是針對(duì)B樹索引而言.Oracle最多允許包含32個(gè)字段的復(fù)合索引
Oracle索引創(chuàng)建策略
1.導(dǎo)入數(shù)據(jù)后再創(chuàng)建索引
2.不需要為很小的表創(chuàng)建索引
3.對(duì)于取值范圍很小的字段(比如性別字段)應(yīng)當(dāng)建立位圖索引
4.限制表中的索引的數(shù)目
5.為索引設(shè)置合適的PCTFREE值
6.存儲(chǔ)索引的表空間***單獨(dú)設(shè)定
創(chuàng)建不唯一索引
- create index emp_ename on employees(ename)
- tablespace users
- storage(......)
- pctfree 0;
創(chuàng)建唯一索引
- create unique index emp_email on employees(email)
- tablespace users;
創(chuàng)建位圖索引
- create bitmap index emp_sex on employees(sex)
- tablespace users;
創(chuàng)建反序索引
- create unique index order_reinx on orders(order_num,order_date)
- tablespace users
- reverse;
創(chuàng)建函數(shù)索引(函數(shù)索引即可以是普通的B樹索引,也可以是位圖索引)
- create index emp_substr_empno
- on employees(substr(empno,1,2))
- tablespace users;
以上介紹Oracle索引創(chuàng)建策略。
【編輯推薦】