|
||||||||||||||||||||||||||||||||||||||
|
Recompiling
invalid Oracle objects
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
and executable. In
Oracle8i, 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. 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 any
migration/upgrade/downgrade. 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 If
you like Oracle tuning, you might enjoy my latest book “Oracle Tuning: The Definitive Reference” by Rampant TechPress. It’s only
$41.95(I don’t think it is right to charge a fortune for books!) and you
can buy it right now at this link: http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm
|
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||