oracle中重建索引

  
  
    數據庫的索引如果有比較頻繁的 Delete 操作, 將可能導致索引產生很多碎片,
所以,在有的時候,需要對所有的索引重新 REBUILD,以便合併索引塊,減少碎
片,提高查詢速度。
SQL> set heading off
SQL> set feedback off
SQL> spool d:index.sql
SQL> SELECT 'alter index ' || index_name || ' rebuild '
||'tablespace INDEXES storage(initial 256K next 256K pctincrease 0);'
FROM all_indexes
WHERE ( tablespace_name != 'INDEXES'
OR next_extent != ( 256 * 1024 )
)
AND owner = USER
SQL>spool off


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章