Oracle數(shù)據(jù)庫失效對象處理詳情
近期對數(shù)據(jù)庫進行巡檢,發(fā)現(xiàn)數(shù)據(jù)庫業(yè)務(wù)用戶(非 SYS/Public
)下存在失效對象。對失效對象進行分析,主要包括失效的視圖、物化視圖、函數(shù)、包、觸發(fā)器等。
思考:
基于以下原因,建議對失效對象進行處理:
1、通過失效的對象,可能能夠反推發(fā)現(xiàn)業(yè)務(wù)軟件問題(業(yè)務(wù)系統(tǒng)功能太多,可能存在測試不充分的問題);
2、如果失效對象太多,業(yè)務(wù)又頻繁調(diào)用的話,擔(dān)心影響數(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;
生成語句后復(fù)制處理批量執(zhí)行即可
3、重新編譯應(yīng)該會解決掉一部分的失效對象,但是仍然會有部分對象無法通過重新編譯解決。對于這部分對象,需要進行人工的逐個分析,現(xiàn)場可以確認(rèn)的進行確認(rèn)處理(有用則修改,無用則刪除),現(xiàn)場不能確認(rèn)的可以和研發(fā)確認(rèn),最終完成對失效對象處理的目的。
如果最終仍有部分無人可以確認(rèn),建議先暫時保留即可。
到此這篇關(guān)于Oracle
數(shù)據(jù)庫失效對象處理詳情的文章就介紹到這了,更多相關(guān)Oracle
數(shù)據(jù)庫失效對象處理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Oracle數(shù)據(jù)庫中建立索引的基本方法講解
這篇文章主要介紹了Oracle數(shù)據(jù)庫中建立索引的基本方法,包括對性能方面進行衡量而給出的一些索引的設(shè)計和使用建議,需要的朋友可以參考下2016-01-01ORALCE?substr函數(shù)及substrb與字符集關(guān)系詳解
這篇文章主要介紹了ORALCE?substr函數(shù)及substrb與字符集關(guān)系,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07登錄oracle數(shù)據(jù)庫時密碼忘記的解決方法
登錄本地oracle數(shù)據(jù)庫時,忘記密碼了,這種情況時有發(fā)生,下面有個不錯的解決方法,希望對大家有所幫助2014-01-01Oracle Database 10g數(shù)據(jù)庫安裝及配置教程
這篇文章主要介紹了Oracle Database 10g Release 2數(shù)據(jù)庫安裝及配置教程,感興趣的小伙伴們可以參考一下2016-08-08