按照顺序或依赖关系重新编译失效的对象

2008-06-10 08:03:35 北京时间
许多情况下,由于数据库的变更或迁移,会导致数据库中的对象失效。由于对象之间可能存在复杂的倚赖关系,所以手工编译通常无法顺利通过。 本文将详细将详细介绍Oracle提供的一个用于按照顺序/依赖关系重新编译失效对象的脚本。

 

脚本:

$ORACLE_HOME/rdbms/admin/utlrp.sql

 

其中会调用:

$ORACLE_HOME/rdbms/admin/utlrcmp.sql

 

在utlrp.sql脚本中,Oracle的注释:

 

Rem utlrp.sql - UTiLity script Recompile invalid Pl/sql modules

 

Rem

 

Rem DESCRIPTION

 

Rem This is a fairly general script that can be used at any time to

 

Rem recompile all existing invalid PL/SQL modules in a database.

 

Rem

 

Rem If run as one of the last steps during migration/upgrade/downgrade

 

Rem (see the README notes for your current release and the Oracle

 

Rem Migration book), this script will validate all PL/SQL modules

 

Rem (procedures, functions, packages, triggers, types, views, libraries)

 

Rem during the migration step itself.

 

Rem

 

Rem Although invalid PL/SQL modules get automatically recompiled on use,

 

Rem it is useful to run this script ahead of time (e.g. as one of the last

 

Rem steps in your migration), since this will either eliminate or

 

Rem minimize subsequent latencies caused due to on-demand automatic

 

Rem recompilation at runtime.

 

Rem

 

Rem Oracle highly recommends running this script towards the end of

 

Rem of any migration/upgrade/downgrade.

 

注:上面这个示例是一个通用脚本,可以在任意时候运行以重新编译数据库失效对象。通常我们会在Oracle的升级指导中看到这个脚本,Oracle强烈推荐在migration/upgrade/downgrade之后,通过运行此脚本编译失效对象。 但是注意,Oracle提醒,此脚本需要用SQLPLUS以SYSDBA身份运行,并且当时数据库中最好不要有活动事物或DDL操作,否则极容易导致死锁的出现(这是很容易理解的)。 只要仔细阅读一下utlrcmp.sql脚本,大家就会知道Oracle的具体操作方式了。




发表评论

请文明参与讨论,禁止漫骂攻击。本站保留不刊登无关和不雅评论的权力。


用户名: 密码: 匿名

相关新闻
由于工程需要经常将客户的现场数据导出到公司的开发环境中,随着
在对数据库进行操作过程中我们可能会遇到这种情况,表中的数据可
根据NULL的定义,NULL表示的是未知,因此两个NULL比较的结果既不
ORACLE 数据库有三种标准的备份方法,它们分别为导出/导入(EXPO
近来公司技术,研发都在问我关于内存参数如何设置可以优化Oracle

广告
© 2008 The Czz5 Company. All Rights Reserved. 关于我们 - 联系我们 - 广告业务 - 网站地图 - 版权声明 - 友情连接 - 网站投稿 - 致信编辑