编译数据库中的失效对象utlrp.sql

本文介绍如何使用Oracle提供的脚本$ORACLE_HOME/rdbms/admin/utlrp.sql来编译数据库中的失效对象,如Package、trigger等。此脚本可以按顺序/依赖关系重新编译所有失效的PL/SQL模块,适用于数据库迁移或升级场景,以减少后续的延迟。运行此脚本前需确保以SYSDBA身份登录并避免数据库中有活动事务或DDL操作,以防止死锁。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何有效的编译数据库中的失效对象(Package,trigger等)

0

很多时候,由于数据库的变更或迁移,会导致数据库中的对象失效。

由于对象之间可能存在复杂的倚赖关系,所以手工编译通常无法顺利通过。

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的操作方式。

列在这里,作为一个提示,供参考。

 

源文档 <http://www.eygle.com/archives/2005/01/ecioaeaoeeeaoea.html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值