Oracle數(shù)據(jù)庫失效對象處理詳情
近期對數(shù)據(jù)庫進行巡檢,發(fā)現(xiàn)數(shù)據(jù)庫業(yè)務用戶(非 SYS/Public
)下存在失效對象。對失效對象進行分析,主要包括失效的視圖、物化視圖、函數(shù)、包、觸發(fā)器等。
思考:
基于以下原因,建議對失效對象進行處理:
1、通過失效的對象,可能能夠反推發(fā)現(xiàn)業(yè)務軟件問題(業(yè)務系統(tǒng)功能太多,可能存在測試不充分的問題);
2、如果失效對象太多,業(yè)務又頻繁調(diào)用的話,擔心影響數(shù)據(jù)庫性能(未進行測試,個人想法,如有錯誤請大家指正);
處理方式:
1、先搜索發(fā)現(xiàn)失效對象(在sys用戶下執(zhí)行)
select owner, object_name, object_type, status from dba_objects t where status='INVALID' order by t.owner,t.object_type;
2、對失效對象自動生成重編譯語句,進行重編譯
下面是為視圖、函數(shù)、物化視圖、包、觸發(fā)器的生成語句。
--自動生成視圖重新編譯語句 select owner, object_name, object_type, status ,'alter view ' || t.owner||'.' || object_name || ' compile'||';' from dba_objects t where status='INVALID' and t.object_type='VIEW' order by t.owner,t.object_type; --自動生成函數(shù)重新編譯語句 select owner, object_name, object_type, status ,'alter FUNCTION ' || t.owner||'.' || object_name || ' compile'||';' from dba_objects t where status='INVALID' and t.object_type='FUNCTION' order by t.owner,t.object_type; --自動生成視物化圖重新編譯語句 select owner, object_name, object_type, status ,'alter MATERIALIZED VIEW ' || t.owner||'.' || object_name || ' compile'||';' from dba_objects t where status='INVALID' and t.object_type='MATERIALIZED VIEW' order by t.owner,t.object_type; --自動生成包重新編譯語句 select owner, object_name, object_type, status ,'alter PACKAGE ' || t.owner||'.' || object_name || ' compile'||';' from dba_objects t where status='INVALID' and t.object_type='PACKAGE BODY' order by t.owner,t.object_type; --自動生成觸發(fā)器重新編譯語句 select owner, object_name, object_type, status ,'alter TRIGGER ' || t.owner||'.' || object_name || ' compile'||';' from dba_objects t where status='INVALID' and t.object_type='TRIGGER' order by t.owner,t.object_type;
生成語句后復制處理批量執(zhí)行即可
3、重新編譯應該會解決掉一部分的失效對象,但是仍然會有部分對象無法通過重新編譯解決。對于這部分對象,需要進行人工的逐個分析,現(xiàn)場可以確認的進行確認處理(有用則修改,無用則刪除),現(xiàn)場不能確認的可以和研發(fā)確認,最終完成對失效對象處理的目的。
如果最終仍有部分無人可以確認,建議先暫時保留即可。
到此這篇關于Oracle
數(shù)據(jù)庫失效對象處理詳情的文章就介紹到這了,更多相關Oracle
數(shù)據(jù)庫失效對象處理內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!
版權聲明:本站文章來源標注為YINGSOO的內(nèi)容版權均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。