元旦快乐
通过DBA_OBJECTS数据字典查找无效对象,并重新编译
复制以下内容,编辑为脚本compile.sql,以sys账号执行
SQL>@compile.sql
REM --------------------------------------------------------------------------
REM
REM compile.sql - Recompiles All Invalid Database Objects
REM
REM This SQL script selects all INVALID database objects from DBA_OBJECTS and
REM attempts to recompile them. It then selects all remaining INVALID database
REM objects to see how many did not compile successfully.
REM
REM --------------------------------------------------------------------------
REM Set the environment variables
set echo off
set feedback off
set pages 0
set lines 100
prompt
prompt ************************************************
prompt Selecting all INVALID objects in the database...
prompt ************************************************
prompt
REM Start spooling the results into a temporary file
spool temp.sql
REM This select statement will generate a list of all invalid database objects
SELECT 'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' || OBJECT_NAME || ' COMPILE;'
FROM DBA_OBJECTS
WHERE STATUS = 'INVALID' AND
OBJECT_TYPE NOT IN ('PACKAGE BODY', 'TYPE BODY');
spool off;
prompt
prompt
prompt ****************************
prompt Compiling INVALID objects...
prompt ****************************
prompt
REM Run the spool file as a series of 'ALTER... COMPILE;' statements
@temp.sql
REM Remove the temporary spool file
host erase temp.sql
prompt
prompt ****************************************
prompt Compilation of INVALID objects complete.
prompt ****************************************
prompt
prompt
prompt **********************************************************
prompt Selecting all remaining INVALID objects in the database...
prompt **********************************************************
prompt
SELECT 'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' || OBJECT_NAME || ' COMPILE;'
FROM DBA_OBJECTS
WHERE STATUS = 'INVALID' AND
OBJECT_TYPE NOT IN ('PACKAGE BODY', 'TYPE BODY');
prompt
REM End of script复制
参考:Example: How to Recompile all Invalid Database Objects (SCR 209) (Doc ID 125780.1)
文章转载自dblife,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle DataGuard高可用性解决方案详解
孙莹
449次阅读
2025-03-26 23:27:33
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
428次阅读
2025-04-15 17:24:06
墨天轮个人数说知识点合集
JiekeXu
375次阅读
2025-04-01 15:56:03
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
363次阅读
2025-04-08 09:12:48
Oracle SQL 执行计划分析与优化指南
Digital Observer
346次阅读
2025-04-01 11:08:44
Oracle 19c RAC更换IP实战,运维必看!
szrsu
312次阅读
2025-04-08 23:57:08
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
301次阅读
2025-04-15 14:48:05
风口浪尖!诚通证券扩容采购Oracle 793万...
Roger的数据库专栏
299次阅读
2025-03-24 09:42:53
切换Oracle归档路径后,不能正常删除原归档路径上的归档文件
dbaking
292次阅读
2025-03-19 14:41:51
oracle定时任务常用攻略
virvle
290次阅读
2025-03-25 16:05:19