Oracle invalid Objects Tips
Oracle Database Tips by Burleson Consulting
Oracle is complex
and interconnected and changing things can cause some database
objects to become "invalid".
This script will
display a list of Oracle invalid objects:
break on c1
set pages 999
col c1 heading 'owner' format a15
col c2 heading 'name' format a40
col c3 heading 'type' format a10
status != 'VALID'
Whenever an oracle object is marked as invalid because of a table,
that has been changed, the Oracle professional can change the object
to valid by using a SQL*Plus script.
This script will search the
Oracle data dictionary for invalid objects, create a spool file with
the names of the invalid objects, then invoke a script to re-compile
all of these invalid objects. The following script should be used
whenever a change is made to an Oracle table or index, or any other
Oracle object, since the DBA must ensure that all objects are valid
We now have a supported script to perform this function of
re-compiling invalid objects. The utility is called Recompile PL/SQL,
or RP for short. The script is called utlrp.sql and is located in the
$ORACLE_HOME/rdbms/admin/ directory. However, most experienced Oracle
DBAs prefer a home-made script for this purpose.
Recompiling invalid objects
Although invalid PL/SQL modules get automatically recompiled on
use, it is useful to run this script ahead of time (e.g. as one of the
last steps in your migration), since this will either eliminate or
minimize subsequent latencies caused due to on-demand automatic
recompilation at runtime.
You can invoke the utl_recomp package to recompile invalid objects:
EXEC UTL_RECOMP.recomp_serial('schema name');
Oracle highly recommends running this script towards the end of of
set heading off;
set feedback off;
set echo off;
Set lines 999;
'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' ||
OBJECT_NAME || ' COMPILE;'
status = 'INVALID'
object_type in ('PACKAGE','FUNCTION','PROCEDURE')
set heading on;
set feedback on;
set echo on;
invalid objects sometimes have dependencies, so it may be necessary to
run the Oracle invalid objects recompile repeatedly.