1. How does the invalid object come?

The Oracle database will invalidate objects if a dependent object is changed. If I rebuild a table, the indexes on that table will become invalid because they use the table'srowids and rebuilding the table changes a row's rowid. It is the same with objects like packages, procedures and functions.

2.Build-in scripts to recompile the invalid objects.

We now have a supported script utlrp.sql located in the $ORACLE_HOME/rdbms/admin/utlrp.sql to do recompile for us.

Below code will list out all the current invalid object and run utlrp.sql to compile all of them.

COLUMN owner format a30
COLUMN object_name format a30 wrap
COLUMN object_type format a30 wrap SET pages 56 lines 130 feedback off echo off
TTITLE "Report of Invalid Objects In Database" skip 2
SELECT owner, object_name, object_type
FROM dba_objects
WHERE status = 'INVALID';
PROMPT "Will now run utlrp.sql to try to recompile objects"
@?/rdbms/admin/utlrp.sql

The following PL/SQL block invokes UTL_RECOMP to recompile invalid objects in the database.
Recompilation time is proportional to the number of invalid objects in the database,
so this command may take a long time to execute on a database with a large number of invalid objects.

Use the following queries to track recompilation progress:

1. Query returning the number of invalid objects remaining. This number should decrease with time.
SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);

2. Query returning the number of objects compiled so far. This number should increase with time.
SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;

This script automatically chooses serial or parallel recompilation based on the number of CPUs
available (parameter cpu_count) multiplied by the number of threads per CPU (parameter parallel_threads_per_cpu).
On RAC, this number is added across all RAC nodes.

UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel recompilation. Jobs are created without instance
affinity so that they can migrate across RAC nodes. Use the following queries to verify
whether UTL_RECOMP jobs are being created and run correctly:

1. Query showing jobs created by UTL_RECOMP
SELECT job_name FROM dba_scheduler_jobs WHERE job_name like 'UTL_RECOMP_SLAVE_%';

2. Query showing UTL_RECOMP jobs that are running
SELECT job_name FROM dba_scheduler_running_jobs WHERE job_name like 'UTL_RECOMP_SLAVE_%';

Below is a sql with a good format to list all the invalid database object.
break on c1 skip 2
set pages 999
col c1 heading 'owner' format a15
col c2 heading 'name' format a40
col c3 heading 'type' format a10
ttitle 'Invalid|Objects'
select
owner c1,
object_type c3,
object_name c2
from
dba_objects
where
status != 'VALID'
order by
owner,
object_type;

3. Recompile with UTL_RECOMP package

EXEC UTL_RECOMP.recomp_serial('schema name');

4. compile command for individual object.

For function:

alter function gpcomp1.fn_load_notes_from_jde compile;

For procedure:

alter procedure gpcomp1.updatetemplate compile;

For view

alter view gpcomp1.gamatchedcashapplied compile;

For public synonym, which can only be recompiled by sys

alter public synonym  gpcrfcode  compile

Here is a script to recompile invalid PL/SQL packages and package bodies.

You may need to run it more than once for dependencies, if you get errors from the script.

Set heading off;
set feedback off;
set echo off;
Set lines 999;

Spool run_invalid.sql

select
   'ALTER ' || OBJECT_TYPE || ' ' ||
   OWNER || '.' || OBJECT_NAME || ' COMPILE;'
from
   dba_objects
where
   status = 'INVALID'
and
   object_type in ('PACKAGE','FUNCTION','PROCEDURE')
;
spool off;
set heading on;
set feedback on;
set echo on;
@run_invalid.sql

check the status of oracle component.

select comp_id,  comp_name,  version, status, namespace, schema from dba_registry;

Recompile the invalid object for oracle.的更多相关文章

  1. Invalid object name ‘sys.configurations’. (Microsoft SQL Server, Error: 208)

    http://blogs.msdn.com/b/ramaprasanna/archive/2009/09/16/invalid-object-name-sys-configurations-micro ...

  2. MacTex XeLaTex xdvipdfmx:fatal: pdf_ref_obj(): passed invalid object. 报错的解决方法

    在使用MacTex配合TexStudio编译beamer的时候,爆出如下错误, xdvipdfmx:fatal: pdf_ref_obj(): passed invalid object. 结果尝试其 ...

  3. Oracle EBS 重新编译无效对象 invalid object

    1.  查看数据库中的无效对象      check oracle object      SQL> select count(*) from dba_objects where status= ...

  4. oracle impdp ORA-02304 invalid object identifier literal

    reference: https://webgeest.blogspot.com/2015/07/ora-39083-ora-02304-on-impdp-datapump.html     解决方法 ...

  5. Know How To Use ID_NULL Function To Search An Object In Oracle Forms

    ID_NULL built in function is used to determine that an object type variable is null or not null in O ...

  6. sql - Invalid object name 'dbo.in$'

    这是我从excel导入的表,用查询的时候,不加前面部分的'dbo',能查出来,好像是owner的原因吧.

  7. sp_executesql invalid object name

    https://stackoverflow.com/questions/10417126/dynamically-named-temp-table-returns-invalid-object-nam ...

  8. Manipulating Data from Oracle Object Storage to ADW with Oracle Data Integrator (ODI)

    0. Introduction and Prerequisites This article presents an overview on how to use Oracle Data Integr ...

  9. Oracle 收缩表大小 Oracle Shrink Table --转载

    从10g开始,oracle开始提供Shrink的命令,假如我们的表空间中支持自动段空间管理 (ASSM),就可以使用这个特性缩小段,即降低HWM.这里需要强调一点,10g的这个新特性,仅对ASSM表空 ...

随机推荐

  1. HTTP请求中的User-Agent 判断浏览器类型的各种方法 网络爬虫的请求标示

    我们知道,当用户发送一个http请求的时候,浏览的的版本信息也包含在了http请求信息中: 如上图所示,请求 google plus 请求头就包含了用户的浏览器信息: User-Agent:Mozil ...

  2. 记linux终端下怎样退出>

    敲命令时候,敲错了,进入了>的提示下,怎么也退不出了.查了资料是按ctrl+c或者ctr+d都能退出

  3. 那些年我们没能bypass的xss filter

    个人很喜欢收集xss payload.在这里把自己平时挖xss时会用到的payloads列出来和大家一起分享.很希望大家能把自己的一些payload也分享出来.(由于 我是linux党,所以本文出现在 ...

  4. 浅试 JNI编程

    好吧,开始我的第一个JNI试验小程序 HelloWorld.java 代码清单 public class HelloWorld { static { System.loadLibrary(" ...

  5. 使用System.out.print/prilntln() 输出时存在的问题

    刚学习Java时第一个接触的method就是System.out.println() 方法.但是最近在使用它输出一些变量时出现了我不理解的现象,首先上代码: /* * * using method S ...

  6. beta-2阶段组员贡献分分配

    组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 bera-2阶段各组员的贡献分分配如下: 姓名 个人工作量 组长评价 个人评价 团队贡献总分 胡丽娜 9 4 4 4.25 林莉 9 4 ...

  7. centos6.5 64位 yum install nginx的默认安装路径

    yum install nginx网站文件存放默认目录 /usr/share/nginx/html 网站默认站点配置 /etc/nginx/conf.d/default.conf 自定义Nginx站点 ...

  8. windows服务器。linux服务器的集成包推荐

    我对linux不熟悉,这个有点不好意思,虽然我是做php开发的.我只是对apache+php+mysql的操作熟悉而已,但是linux的服务器配置什么的都太懂 所以我就安装了windows2008,安 ...

  9. 前端CSS参考阅读

    CSS 2.2 W3标准 http://dev.w3.org/csswg/css2/ CSS2 中文翻译 http://files.cnblogs.com/files/mize/CSS2_Chines ...

  10. Visual Studio解决方案及项目的配置

    配置解决方案的属性 1.配置解决方案平台,该配置实际上修改的是解决方案目录下的sln(solution)文件. 配置项目的属性 1.配置项目平台及项目的目标平台:项目-右键-属性-生成(竖着第二个选项 ...