Chinaunix首页 | 论坛 | 博客
  • 博客访问: 374294
  • 博文数量: 113
  • 博客积分: 3035
  • 博客等级: 中校
  • 技术积分: 1430
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-01 16:32
文章分类
文章存档

2011年(42)

2010年(70)

2009年(1)

我的朋友

分类: Oracle

2011-07-12 09:31:03

在数据库升级、打补丁或者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.
阅读(1727) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~