標籤:增刪改查 _id 常見 uil 清除 AC 位元影像索引 space sele
oracle常見的索引是BTree索引和Bitmap索引。
BTree索引特點:
預設索引
適合大量增刪改查
不能用or操作符
適合高基數的列(即唯一值多)
建立sql:create index lie_idx1 on table(liename);
Bitmap索引特點:
做update代價非常高
非常適合or操作符
基數少的列(即重複值多)
建立sql:create bitmap index lie_bit_idx1 on table(liename);
Bitmap索引使用配註:
對列做位元影像索引(Bitmap),該列必須是不常改動的。因為oracle在查詢位元影像索引時,會將尋找的某一重複值都鎖定,在一個sql未提交前,其他使用者操作擁有該重複值的sql會處於阻塞狀態,直至第一個sql被提交。
建立索引的一些規則:
1、權衡索引和DML之間的關係。執行DML語句會修改索引
2、把索引和表資料放在不同的資料表空間。讀取表資料時可以並行讀取索引【移動索引:alter index indexname rebuild tablespace】
索引的常用操作:
重新建立索引:alter index indexname rebuild tablespace indexname2; 資料庫操作刪除命令後,索引記錄並不會馬上清除
線上重建索引:alter index indexname rebuild online;
整合索引:alter index indexname coalesce; 用於整理索引片段
刪除索引:drop index scott.indexname;
分析索引:
1、查詢存放分析資料的表:select count(*) from index_status;
2、執行分析索引命令:analyze index indexname validate structrue; --分析完該索引資訊會存於index_status表中。
oracle之bitmap索引