oracle如何复制表的索引,Oracle表与索引管理
1.分析表與索引
analyze table tablename compute statistics
等同于
analyze table tablename compute statistics for table for all indexes for all columns
analyze index 索引ID compute statistics;
2、一般來講可以采用以下三種方式來手工分析索引。
analyze index idx_t validate structure:
analyze index idx_t compute statistics:
analyze index idx_t estimate statistics sample 10 percent
1)analyze index idx_t validate structure:
這段分析語句是用來分析索引的block中是否有壞塊兒,那么根據(jù)分析我們可以得到索引的結(jié)構(gòu)數(shù)據(jù),這些數(shù)據(jù)會(huì)保留到
index_stats中,來判斷這個(gè)索引是否需要rebuild. 需要注意的是這樣的分析是不會(huì)收集索引的統(tǒng)計(jì)信息的。
2)validate structure有二種模式: online, offline, 一般來講默認(rèn)的方式是offline。
當(dāng)以offline的模式analyze索引時(shí),會(huì)對table加一個(gè)表級共享鎖,對目前table的一些實(shí)時(shí)DMl操作會(huì)產(chǎn)生一定的影響。
而以online模式分析時(shí)候,則不會(huì)加任何lock,但在index_stats中是看不到任何信息的。
3)analyze index idx_t compute statistics:
用來統(tǒng)計(jì)索引的統(tǒng)計(jì)信息(全分析),主要為CBO服務(wù)。
4)analyze index idx_t estimate statistics sample 10 percent
主要是用來指定比例進(jìn)行抽樣分析,也是為CBO服務(wù). 例中是抽樣10%
3.重建索引
alter index index_name rebuild tablespace tablespace_name
alter index index_name rebuild tablespace tablespace_name 加入表空間名,會(huì)將指定的索引移動(dòng)到指定的表空間當(dāng)中。
4、其他的統(tǒng)計(jì)方法
--分析表
exec dbms_stats.gather_table_stats(ownname => USERNAME,tabname =>TABLENAME,estimate_percent => 10,method_opt=> 'for all indexed columns');
--分析索引
exec dbms_stats.gather_index_stats(ownname =>USERNAME,indname =>INDEX_NAME,estimate_percent => '10',degree => '4');
--如果發(fā)現(xiàn)執(zhí)行計(jì)劃走錯(cuò),刪除表的統(tǒng)計(jì)信息
exec dbms_stats.delete_table_stats(ownname =>USERNAME,tabname =>TABLENAME) ;
總結(jié)
以上是生活随笔為你收集整理的oracle如何复制表的索引,Oracle表与索引管理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 报表建oracle表,建立Oracle
- 下一篇: 最小生成树实验报告c语言,最小生成树(C