gdufo

           

          oracle 索引管理

          第四章:索引

          1.creating function-based indexes

          sql> create index summit.item_quantity on summit.item(quantity-

          quantity_shipped);

          2.create a B-tree index  #oracle 默認是這種索引,此種索引適用于唯一性高的列

          sql> create [unique] index index_name on table_name(column,.. asc/desc)

          tablespace

          sql> tablespace_name [pctfree integer] [initrans integer] [maxtrans integer] #不能指定pctused參數

          sql> [logging | nologging] [nosort] storage(initial 200k next 200k pctincrease 0

          sql> maxextents 50);

          3.pctfree(index)=(maximum number of rows-initial number of rows)*100/maximum

          number of rows

          4.creating reverse key indexes

          sql> create unique index xay_id on xay(a) reverse pctfree 30 storage(initial

          200k
          next 200k pctincrease 0 maxextents 50) tablespace indx;

          5.create bitmap index #此種索引適用于唯一性低的列,如性別列,只有"男","女"兩種

          情況,也就是說,很多行會重復。

          sql> create bitmap index xay_id on xay(a) pctfree 30 storage( initial 200k next

          200k

          sql> pctincrease 0 maxextents 50) tablespace indx;

          6.change storage parameter of index

          sql> alter index xay_id storage (next 400k maxextents 100);

          7.allocating index space

          sql> alter index xay_id allocate extent(size 200k datafile

          'c:/oracle/index.dbf');

          8.deallocating index space
          sql> alter index xay_id deallocate unused;

          9.rebuilding indexes
          sql> alter index testindex3 rebuild tablespace indx;#移到指定tablespace

          sql> alter index testindex3 rebuild reverse;#轉換成反轉索引

          10.online rebuild of indexes
          sql> alter index testindex3 rebuild online #不鎖定表,原有索引的基礎上建

          11.coalescing indexes 碎片整理
          sql> alter index testindex3 coalesce;

          12.checking index validity  校驗索引
          sql> analyze index testindex validate structrue;

          13.dropping indexes
          sql> drop index testindex;

          14.identifying unused indexes
          sql> alter index testindex monitoring useage;   #開始監視
          sql> alter index testindex nomonitoring useage; #取消監視

          15. obtaining index information
             dba_indexes, dba_ind_columns, dba_ind_expressions,v$object_usage
          16.oracle B-tree和bitmap索引區別
          1、都是樹型結構,葉子節點存儲內容不一樣。
          2、列的取值范圍較大(適合常規b—tree索
          引),取值范圍較小(適合位圖索引);
          3、由于bitmap索引的特點,他不是unique型的,
          也不涉及unique概念。
          4、bitmap通常where如果有or連接效率比較高。
          5、b-tree適合
          oltp,bitmap適合數據倉庫。

          16.索引占用空間使用情況
          sql>analyze index ***.***_subscriber_groupid_indx validate structure;
          Index analyzed.

          column name format a15
          column blocks heading "ALLOCATED|BLOCKS"
          column lf_blks heading "LEAF|BLOCKS"
          column br_blks heading "BRANCH|BLOCKS"
          column Empty heading "UNUSED|BLOCKS"

          SQL> list
          1  select name,
          2         blocks,
          3         lf_blks,
          4         br_blks,
          5         blocks-(lf_blks+br_blks) empty
          6* from   index_stats
          SQL> /
          ALLOCATED       LEAF     BRANCH     UNUSED
          NAME                BLOCKS     BLOCKS     BLOCKS     BLOCKS
          ————— ———- ———- ———- ———-
          ***_SUBSCRIBER        640        577          3         60
          _GROUPID_INDX

          也可通過如下的查詢來確定該索引在BTREE空間內使用情況

          SQL> list
          1  select name,
          2         btree_space,
          3         used_space,
          4         pct_used
          5* from   index_stats
          SQL> /

          NAME                           BTREE_SPACE USED_SPACE   PCT_USED
          —————————— ———– ———- ———-
          AGCF_SUBSCRIBER_GROUPID_INDX       4637776    3027283         66



           

          posted on 2009-11-22 18:18 gdufo 閱讀(529) 評論(0)  編輯  收藏 所屬分類: Database (oracle, sqlser,MYSQL)

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 友谊县| 白山市| 平江县| 新野县| 浙江省| 马山县| 宁乡县| 达日县| 昌图县| 曲沃县| 涞源县| 项城市| 巴彦淖尔市| 泰和县| 蓬莱市| 忻州市| 文成县| 云和县| 湘阴县| 西华县| 涿州市| 双辽市| 井陉县| 瑞丽市| 双牌县| 桓台县| 洛浦县| 崇州市| 宁国市| 石棉县| 甘洛县| 和硕县| 醴陵市| 太和县| 永胜县| 和龙市| 南昌市| 桦南县| 枣阳市| 寿阳县| 玉溪市|