oracle重新编译失效对像

重新编译失效对像可执行utlrp.sql文件:

SQL> @?/rdbms/admin/utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN  2016-08-24 13:04:49

DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like ‘UTL_RECOMP_SLAVE_%‘;
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like ‘UTL_RECOMP_SLAVE_%‘;
DOC>#

PL/SQL 过程已成功完成。

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END  2016-08-24 13:04:50

PL/SQL 过程已成功完成。

DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  4

DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0

PL/SQL 过程已成功完成。

进一步研究文件sql文件,可以看到,在默认情况下Oracle会调用存储过程utl_recomp.recomp_parallel并行编译无效包:

begin
  sys.UTL_RECOMP.recomp_parallel(0);
end;

当threads取值为0时,由Oracle根据参数cpu_count和parallel_threads_per_cpu自行决定并行度;

SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------
cpu_count                            integer     4
parallel_threads_per_cpu             integer     2

有时候,由于Oracle bug 14065287,在启用并行编译无效对象时,脚本utlrp.sql会出现HANG现象,这时需要启用串行编译无效对象,如下所示:

BEGIN
   sys.utl_recomp.recomp_serial();
END;

注意:如果在执行中,中断了,下次如果再次执行时,有可能会出现名称已由现有对像使用,要在重编译前先删除下列索引

drop index SYS.UTL_RECOMP_COMP_IDX1;

使用并行执行时,会使用到SGA中的large pool,如果large pool大小不够大,会报如下错误:

ORA-12801: 并行查询服务器 P012 中发出错误信号
ORA-12853: PX 缓冲区的内存不足: 当前为 16336K, 最大需要 178560K
ORA-04031: 无法分配 65560 字节的共享内存 ("large pool","unknown object","large pool","PX msg pool")
ORA-06512: 在 "SYS.UTL_RECOMP", line 865
ORA-06512: 在 line 2

如果不是sys用户执行,可先授予相关的执行权限:

grant execute on UTL_RECOMP to XXX;
时间: 2024-08-03 17:47:46

oracle重新编译失效对像的相关文章

ORACLE编译失效对象

 数据库对象失效原因 数据库对象失效的原因很多,下面大致归纳了一些常见的原因: 1: 当被引用对象的结构变更时,都会使得相关的依赖对象转变为INVALID状态. 数据库中的对象(存储过程,函数,包,视图,触发器),它们往往需要直接或者间接的引用其它对象,对象的依赖包括直接和间接二种,其中直接依赖是指存储对象直接依赖于被引用对象,而间接依赖是指对象间接依赖于被引用对象 要查看被引用的对象,可以通过下面SQL查看 SELECT * FROM dba_dependencies WHERE NAME

自动编译失效的Oracle数据库对象

昨天看有个帖子说到的失效对象重新编译的问题,然后发现自己公司里也出现莫名其妙的失效对象. --创建自动编译失效过程事务记录表 declare tabcnt integer := 0; begin select count(*) into tabcnt from dba_tables where table_name='RECOMPILE_LOG'; if tabcnt = 0 then execute immediate 'create table recompile_log(rdate dat

oracle 重新编译用户无效对象

oracle sys用户无效对象 select owner,object_name , replace(object_type,' ','') object_type ,to_char(created,'yyyy-mm-dd') as created ,to_char(last_ddl_time,'yyyy-mm-dd') as last_ddl_time, status from dba_objects where status='INVALID' and owner='SYS'; OWNER

转://oracle 重新编译用户无效对象

select owner,object_name, replace(object_type,' ','') object_type,to_char(created,'yyyy-mm-dd') as created,to_char(last_ddl_time,'yyyy-mm-dd') as last_ddl_time,status from dba_objects where status='INVALID' and owner='SYS'; OWNER OBJECT_NAME OBJECT_T

如何编译失效对象

--编译失效对象 begin dbms_utility.compile_schema(user, false); end;

在ORACLE中找出并批量编译失效的对象

每次数据库升级之后,都需要对库中的对象进行重新编译一下.下面整理出了一个脚本,只需要执行一下就能批量编译这些失效的对象.需要注意的是:因权限问题,最好是选择sys用户来执行这个脚本,如是plsql developer中执行,记得选择"ALL USERS"      [[email protected] ~]$ cat check_compile.sql  set heading off;  set feedback off;  set echo off;  Set lines 999;

记一次oracle视图查询失效的情况,ERROR at line 1: ORA-04045: errors during recompilation/revalidation of NC633.BB_API_BUDGET_EXEINFO ORA-16000: database open for read-only access

背景:oracle主库和dg库,在dg库上只读.发现查询有报错. 2.查询失效的视图数量: SQL> SELECT COUNT(1) FROM DBA_OBJECTS WHERE STATUS='INVALID'; 3.在主库上面重新编译所有视图即可. SQL> @utlrp.sql; 当然,也可以单独编译单个视图:ALTER  VIEW view_name COMPILE; 原文地址:https://www.cnblogs.com/xingyunfashi/p/12312117.html

Oracle 11g 编译使用BBED

环境:RHEL 6.4 + Oracle 11.2.0.4 1. 拷贝缺失文件 2. 编译BBED 3. BBED使用测试 Reference 1. 拷贝缺失文件 11g中缺失几个相关文件,但我们实际可以从10g拷贝相关文件到11g对应目录下: $ORACLE_HOME/rdbms/lib/sbbdpt.o $ORACLE_HOME/rdbms/lib/ssbbded.o $ORACLE_HOME/rdbms/mesg/bbedus.msb $ORACLE_HOME/rdbms/mesg/bbe

Oracle 索引的失效和重建

查询指定表的索引 SELECT T1.TABLE_NAME, T1.INDEX_NAME, T1.INDEX_TYPE, T1.UNIQUENESS, T1.TABLE_OWNER, T1.STATUS, T1.FUNCIDX_STATUS FROM ALL_INDEXES T1 WHERE T1.TABLE_OWNER = UPPER('&Owner') AND T1.TABLE_NAME = UPPER('&Table_Name') ORDER BY T1.STATUS DESC; 普