自動(dòng)重建失效index的shell腳本怎么寫,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
創(chuàng)新互聯(lián)公司是專業(yè)的余杭網(wǎng)站建設(shè)公司,余杭接單;提供成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行余杭網(wǎng)站開發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
自動(dòng)重建失效index的shell腳本
腳本每一個(gè)小時(shí)運(yùn)行一次,檢測(cè)失效索引,一旦發(fā)現(xiàn)立刻重建
腳本全部?jī)?nèi)容如下:
[oracle@orac1 pump]$ more /home/oracle/tools/rebuild_index.sh
#Enviroment define.
source /home/oracle/tools/SET_JOB_ENV.sh
export PATH=$PATH
#following is excution part
sqlplus / as sysdba <<eof
declare
begin
for i in (select index_name,owner from dba_indexes where status ='UNUSABLE' and wner='EDW1_USER') loop
execute immediate 'alter index '||i.owner||'.'||i.index_name||' rebuild online';
end loop;
for j in (select index_name,partition_name,index_owner from dba_ind_partitions where status ='UNUSABLE' and index_owner='EDW1_USER') loop
execute immediate 'alter index '||j.index_owner||'.'||j.index_name|| ' rebuild partition '||j.partition_name||' online';
end loop;
end;
/
exit
eof
其中為環(huán)境變量設(shè)置腳本為
[oracle@orac1 pump]$ more /home/oracle/tools/SET_JOB_ENV.sh
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
#oracle env
ORACLE_BASE=/data/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2/db1
ORA_CRS_HOME=$ORACLE_BASE/product/10.2/crs
export ORACLE_BASE ORACLE_HOME
ORACLE_SID=justin
export ORACLE_SID
ORACLE_TERM=xterm
export ORACLE_TERM
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export CLASSPATH
PATH=$HOME/bin:$ORACLE_HOME/bin:$PATH:$ORA_CRS_HOME/bin
NLS_LANG=AMERICAN_AMERICA.UTF8
添加至crontab
#check the unusable index and rebuild them online if exists
01 */1 * * * sh /home/oracle/tools/rebuild_index.sh
看完上述內(nèi)容,你們掌握自動(dòng)重建失效index的shell腳本怎么寫的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
當(dāng)前標(biāo)題:自動(dòng)重建失效index的shell腳本怎么寫
文章轉(zhuǎn)載:http://chinadenli.net/article14/jdpdde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、網(wǎng)站建設(shè)、搜索引擎優(yōu)化、建站公司、網(wǎng)頁(yè)設(shè)計(jì)公司、營(yíng)銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)