在数据库升级、打补丁或者imp全库时可能会碰到对象失效的情况,这里提供了三种办法重新编译:
一、单个对象逐一编译
select
'alter '||object_type||' '||'"'||owner||'"'||'.'||object_name||' compile;' from dba_objects
where status='INVALID'
order by object_type;
二、整个OWNER编译
dbms_utility.compile_schema(
schema IN VARCHAR2,
compile_all IN BOOLEAN DEFAULT TRUE,
reuse_settings IN BOOLEAN DEFAULT FALSE);
举例
exec dbms_utility.compile_schema('SCOTT');
三、全库编译
spool logfile
@?/rdbms/admin/utlrp.sql;
spool off
关于utlrp.sql and utlprp.sql的说明如下:
The utlrp.sql and utlprp.sql scripts are provided by Oracle to recompile all invalid objects in the database. They are typically run after major database changes such as upgrades or patches. They are located in the $ORACLE_HOME/rdbms/admin directory and provide a wrapper on the UTL_RECOMP package. The utlrp.sql script simply calls the utlprp.sql script with a command line parameter of "0". The utlprp.sql accepts a single integer parameter that indicates the level of parallelism as follows:
0 - The level of parallelism is derived based on the CPU_COUNT parameter.
1 - The recompilation is run serially, one object at a time.
N - The recompilation is run in parallel with "N" number of threads.
Both scripts must be run as the SYS user, or another user with SYSDBA, to work correctly.
阅读(1761) | 评论(0) | 转发(0) |