oracle compile 编译无效对象

原博主:http://blog.csdn.net/tianlesoftware/article/details/4843600 

Applies to: 
Oracle Server - Enterprise Edition - Version: 10.1.0.5.0 
This problem can occur on any platform. 
Symptoms: 
The issue is that the following error was raised : 
ORA-00600: internal error code, arguments: [kesutlGetBindValue-2], [], [], [], [], [], [], [] 
The recent changes was the : 
Migration from 10.1.0.5.0 database control to Grid Control Agent v10.2.0.3.0 
What was runing at this moment of the error occurance was : 
The attempt to run SQL Tuning Advisor from Grid Control

Cause: 
Possibly invalid objects in the database. 
As the issue here was to try to use these packages and then failed: 
SYS.DBMS_SQLTUNE_INTERNAL 
body SYS.PRVT_ADVISOR 
body SYS.DBMS_ADVISOR 
body SYS.DBMS_SQLTUNE 
And as mentioned with the recent changes was the migration.

Solution: 
1. fixup 
1). connect to the database as sysdba: 
sqlplus "/ as sysdba" 
2). shutdown immediate 
3). startup migrate 
4). @?/rdbms/admin/catalog.sql 
5). @?/rdbms/admin/catproc.sql 
6). @?/rdbms/admin/utlrp.sql 
7). shutdown immediate 
8). startup

SELECT UNIQUE OBJECT_TYPE FROM ALL_objects where status = ‘INVALID‘; 
select ‘ALTER ‘ || OBJECT_TYPE || ‘ ‘||owner||‘.‘ || OBJECT_NAME || ‘ COMPILE;‘ 
from  all_objects where  status = ‘INVALID‘ 
and  object_type in (‘PACKAGE‘,‘FUNCTION‘,‘PROCEDURE‘, ‘TABLE‘, ‘VIEW‘, ‘SEQUENCE‘, ‘TRIGGER‘); 
   
     
   SELECT * from dba_users; 
   select ‘ALTER PACKAGE ‘ || OWNER||‘.‘|| OBJECT_NAME || ‘ COMPILE body;‘ 
from ALL_objects where status = ‘INVALID‘ and object_type in (‘PACKAGE BODY‘); 
SELECT UNIQUE OBJECT_TYPE FROM ALL_OBJECTS;

2. Verify that the status of the CATPROC : 
SQL> col comp_id format a10 
SQL> col comp_name format a30 
SQL> col version format a10 
SQL> select comp_id, comp_name, status, version from dba_registry;

and the status of the other objects: 
SQL> col object_name format a30 
SQL> col owner format a15 
SQL> select object_name, owner, object_type, status from dba_objects 
where status = ‘INVALID‘;

2-If they are invalid please do the following: 
To validate the invalid objects 
1)-Please run the utlrp.sql script to try and validate the invalid packages, then check if they are valid or still invalid. 
2 )-If the objects are still invalid after running the utlrp.sql script then run catalog.sql and catproc.sql and then run utlrp.sql 
    a) Startup restrict or startup migrate. 
    b) run catalog.sql 
    c) run catproc.sql 
    d) run utlrp.sql 
3 )-Requery for the invalid objects again. 
select owner,object_type,object_name from dba_objects where status=‘INVALID‘ ; 
4 )-If they are still invalid please try to validate them manually using the below: 
Try Manual method of validation: 
Alter procedure <owner>.<procedure_name> compile; 
Alter function <owner>.<function_name> compile; 
Alter view <owner>.<view_name> compile; 
Alter package <owner>.<package_name> compile; 
Alter package <owner>.<package_name> compile body; 
Alter materialized view <owner>.<Package_name> Compile; 
In case you have lots of invalid objects,you can generate scripts that will generate the sqls for compiling the invalid objects : 
In sqlplus connect as sys: 
set heading off 
spool compileinvalid.sql 
select ‘alter ‘||object_type|| ‘ ‘ || owner ||‘.‘||object_name || ‘ compile;‘ from dba_objects 
where status=‘INVALID‘; 
spool off 
ORA-06512: at "PS_SYSTEM.ROW_VALIDATOR_T", line 912 
ORA-06512: at "PS_SYSTEM.ROW_VALIDATOR_T", line 924 
ORA-06512: at "WORKORDER.INVENTORY_UTL", line 1260 
select owner,object_name,object_type,status from all_objects where object_name=‘ROW_VALIDATOR_T‘ and owner=‘PS_SYSTEM‘; 
OWNER                          OBJECT_NAME                        OBJECT_TYPE       STATUS 
------------------------------ ------------------------------ ------------------- ------- 
PS_SYSTEM                      ROW_VALIDATOR_T           TYPE                      VALID 
PS_SYSTEM                      ROW_VALIDATOR_T          TYPE BODY           VALID

SQL> select owner,object_name,object_type,status from all_objects where object_name=‘INVENTORY_UTL‘ and owner=‘WORKORDER‘ 
  2  ; 
OWNER                             OBJECT_NAME                     OBJECT_TYPE          STATUS 
------------------------------ ------------------------------ -------------------      ------- 
WORKORDER                      INVENTORY_UTL           PACKAGE                  VALID 
WORKORDER                      INVENTORY_UTL           PACKAGE BODY       VALID

Then run compileinvalid.sql in sqlplus prompt as sys user.. 
To compile invalid package body use: 
alter package <package_name> compile body;

5 )-Also you could do the following  Note 100419.1  SCRIPT: VALIDATE.SQL to ANALYZE VALIDATE 
STRUCTURE objects in a Tablespace 
Please Go through the above action plan and i will be waiting for your update. 
6 )-Please make sure that these packages are valid: 
SYS.DBMS_SQLTUNE_INTERNAL 
body SYS.PRVT_ADVISOR 
body SYS.DBMS_ADVISOR 
body SYS.DBMS_SQLTUNE

References 
Note 100419.1 - SCRIPT: VALIDATE.SQL to ANALYZE .. VALIDATE STRUCTURE objects in a Tablespace

alter PACKAGE BODY SYS.DBMS_XPLAN body compile; 
alter PACKAGE BODY SYS.DBMS_SQLTUNE_INTERNAL body compile; 
alter SYNONYM PUBLIC.HHLINEOR compile; 
alter SYNONYM PUBLIC.HHNEIGHBOUR compile; 
alter SYNONYM PUBLIC.HHLINEPS compile; 
alter SYNONYM PUBLIC.HHIDROWS compile; 
alter SYNONYM PUBLIC.HHIDLROWS compile; 
alter SYNONYM PUBLIC.HHBITS compile;

---------无效索引查询 ‘INVALID INDEXES‘

select s2.owner, s2.tablespace_name, s2.segment_name, 
        i2.table_name, s2.extents, s2.bytes, s2.blocks, i2.status 
from dba_segments s2, 
        dba_indexes i2 
where s2.owner not in (‘SYS‘,‘SYSTEM‘) 
and s2.segment_type = ‘INDEX‘ 
and i2.status != ‘VALID‘ 
and s2.segment_name = i2.index_name 
and s2.owner = i2.owner 
order by 1,5,4

Oracle常用脚本
-- use sys to run this one
select    ‘ALTER ‘ || OBJECT_TYPE || ‘ ‘||owner||‘.‘ || OBJECT_NAME || ‘ COMPILE;‘ 
from    all_objects 
where    status = ‘INVALID‘ 
and object_type in (‘PACKAGE‘,‘FUNCTION‘,‘PROCEDURE‘, ‘TABLE‘, ‘VIEW‘, ‘SEQUENCE‘, ‘TRIGGER‘);

--   select 
   ‘ANALYZE ‘ || OBJECT_TYPE || ‘ ‘ || OBJECT_NAME || ‘ COMPUTE STATISTICS;‘ 
from 
   user_objects 
where 
   object_type = ‘TABLE‘;

时间: 2024-10-05 09:36:50

oracle compile 编译无效对象的相关文章

批量编译无效对象

sqlplus "/as sysdba"@$ORACLE_HOME\RDBMS\ADMIN\utlrp.sql; this script will compile all invalid objects in database 自己编写的一个脚本 $ more check.sqlset head offset pagesize 2000spool comp.sqlselect 'alter '||decode(object_type, 'VIEW', 'VIEW','TRIGGER',

Oracle编译用户无效对象

在采用IMPDP/IMP工具迁移数据时,经常会提示无效对象的警告,需要采用如下方式处理. 1. 查询指定用户的无效对象 su – oracle sqlplus / as sysdba SQL> 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

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重新编译失效对像

重新编译失效对像可执行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 recom

转://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

ORACLE编译失效对象

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

处理Oracle数据中的无效对象

今天还原了一份数据库(在服务器上没有无效对象),还原在本地之后有三十几个无效对象,当时很是郁闷,然后我发现还原之后的数据库中缺少表! 开始我怀疑Oracle数据库的还原功能,但是在我创建表的时候发现,原来是我本地数据库中表空间和服务器上的不一致.然后我在网上找到了解决方案: select username, default_tablespace from dba_users where username='NAXZXXBM';--查找某用户的默认表空间alter tablespace USERS

Python: 字符串搜索和匹配,re.compile() 编译正则表达式字符串,然后使用match() , findall() 或者finditer() 等方法

1. 使用find()方法 >>> text = 'yeah, but no, but yeah, but no, but yeah' >>> text.find('no')10 2. 使用re.match() 对于复杂的匹配需要使用正则表达式和re 模块.为了解释正则表达式的基本原理,假设想匹配数字格式的日期字符串比如11/27/2012 ,可以这样做:>>> text1 = '11/27/2012'>>> text2 = 'Nov

使用SSH操作Oracle中BLOB大对象

package entity; /** * Bigobject entity. @author MyEclipse Persistence Tools */ public class Bigobject implements java.io.Serializable { // Fields private Integer id; private byte[] tblob; private String filename; // Constructors /** default construct