oracle四大索引类型,oracle 索引类型
索引的分類
1二叉樹索引或者叫B數(shù)索引(B-tree indexes),B樹索引是使用最多的一種索引.在默認(rèn)情況下,我們創(chuàng)建的索引都是B樹索引.B樹索引基于二叉樹原理
2.二叉樹聚簇索引(B-tree Cluster indexes) 主要用于聚簇
3.哈希聚簇索引(Hash Cluster indexes) 主要用于哈希(Hash)聚簇
4.反向索引(Reverse Key indexes) 反向索引也屬于B樹索引,它把索引值按字節(jié)反轉(zhuǎn)過來.
5.位圖索引(Bitmap indexes) 指通過位圖對索引進(jìn)行管理,位圖索引適合唯一值很少的列,也就是重復(fù)值很多的列位圖連接索引(Bitmap Join indexes) 用于兩個表的連接
6.基于函數(shù)的索引(Function-Based indexes)如果在sql語句的where字句中經(jīng)常用到函數(shù)或者表達(dá)式,則可以創(chuàng)建基于函數(shù)的索引.
創(chuàng)建索引
create index ?idx_emp1_ename on emp1(ename);
創(chuàng)建唯一索引
create unique index idx_uq_emp1_empno on emp1(empno) tablespace mypl;
創(chuàng)建位圖索引
create bitmap index idx_bm_emp1_deptno on emp1(deptno);
創(chuàng)建反向索引
create index idx_reverse_emp1_ename on emp1(empno);
創(chuàng)建函數(shù)索引
create index idx_funs_emp1_ename on emp1 (upper(ename));
重建索引更換索引所在表空間
alter index idx_reverse_emp1_ename rebuild;
alter index idx_reverse_emp1_ename rebuild tablespace mypl;
刪除索引
drop index idx_reverse_emp1_ename;
查看用戶有哪些索引
select INDEX_NAME,INDEX_TYPE,TABLE_OWNER,TABLE_NAME,TABLE_TYPE from?user_indexes;
查看索引所在表空間
select index_name,tablespace_name from dba_indexes;
分析索引后查看索引統(tǒng)計信息
analyze index idx_funs_emp1_ename validate structure;
select height,(DEL_LF_ROWS_LEN/ LF_ROWS_LEN)*100,blocks,BTREE_SPACE,USED_SPACE from index_stats;
如果(DEL_LF_ROWS_LEN/ LF_ROWS_LEN)*100的值大于20 或 heighr 大于4 需要考慮重建索引
(index_stats存放索引的統(tǒng)計信息; DEL_LF_ROWS表示刪除行數(shù) LF_ROWS表示總行數(shù),height 表示二叉樹從根到葉塊的層次)
總結(jié)
以上是生活随笔為你收集整理的oracle四大索引类型,oracle 索引类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言画bode图程序,根据上位机测得的
- 下一篇: qt中将数据存入文档再读出-------