select own..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Oracle編譯用戶無效對(duì)象

發(fā)布時(shí)間:2020-07-02 20:02:37 來源:網(wǎng)絡(luò) 閱讀:634 作者:koumm 欄目:關(guān)系型數(shù)據(jù)庫(kù)

在采用IMPDP/IMP工具遷移數(shù)據(jù)時(shí),經(jīng)常會(huì)提示無效對(duì)象的警告,需要采用如下方式處理。

1. 查詢指定用戶的無效對(duì)象

su – oracle

sqlplus / as sysdba

SQL> select owner,object_name,replace(object_type,' ','') object_type,to_char(created,'yyyy-mm-dd') as created,to_char(last_ddl_time,'yyyy-mm-dd') as last_ddl_time,status from dba_objects where status='INVALID' and owner='HKJJW';  
OWNER      OBJECT_NAME                    OBJECT_TYPE     CREATED    LAST_DDL_T STATUS    
---------- ------------------------------ --------------- ---------- ---------- -------    
HKJJW      FUNC_RETURN_PY                 FUNCTION        2013-08-02 2013-08-02 INVALID    
HKJJW      MONITORING_FLOW_PARALLEL_VIEW  VIEW            2013-08-02 2013-08-02 INVALID    
HKJJW      TEST                           VIEW            2013-08-02 2013-08-02 INVALID

指定查詢某用戶無效對(duì)象。

SQL> select * from dba_objects where status<>'VALID' and owner='HKJJW';

 

2. 手動(dòng)執(zhí)行編譯或

ALTER FUNCTION HKJJW.FUNC_RETURN_PY COMPILE;  
ALTER VIEW HKJJW.MONITORING_FLOW_PARALLEL_VIEW COMPILE;    
ALTER VIEW HKJJW.TEST COMPILE;

如果是index的話,需要重建.  
alter index index_name rebuild;

如果是package body  
alter package DBMS_CUBE  compile body;

 

3. 自動(dòng)生成編譯無效對(duì)象SQL

1) 統(tǒng)計(jì)當(dāng)前用戶無效對(duì)象數(shù)量:

SQL> select owner,object_type,status,count(*) from dba_objects where status='INVALID' group by owner,object_type,status order by owner,object_type;

OWNER                          OBJECT_TYPE         STATUS    COUNT(*)  
------------------------------ ------------------- ------- ----------    
HNADEV_GROUP                   FUNCTION            INVALID          1    
HNADEV_GROUP                   PACKAGE BODY        INVALID         35    
HNADEV_GROUP                   VIEW                INVALID          7

2) 生成編譯無效對(duì)象SQL

SQL> select  'ALTER ' || OBJECT_TYPE || ' ' ||  OWNER || '.' || OBJECT_NAME || ' COMPILE;' from dba_objects where status = 'INVALID' and object_type in ('PACKAGE','PACKAGE BODY','FUNCTION','PROCEDURE','TRIGGER','VIEW') ; 

'ALTER'||OBJECT_TYPE||''||OWNER||'.'||OBJECT_NAME||'COMPILE;'  
----------------------------------------------------------------------    
ALTER VIEW HNADEV_GROUP.V_E_T_FEEMONTH_CAL COMPILE;    
ALTER VIEW HNADEV_GROUP.V_E_T_FEEMONTH COMPILE;    
ALTER VIEW HNADEV_GROUP.V_E_Z_BILL_STAY_GROUP COMPILE;    
略...    
通過復(fù)制以上SQL語句,直接手動(dòng)執(zhí)行編譯執(zhí)行.

 

4. 也可以采用如下方式在oracle用戶下進(jìn)行手工編譯

# su - oracle  
$ sqlplus / as sysdba    
SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI