Sei sulla pagina 1di 2

INVALID OBJECTS

70. How to identify invalid objects?


SELECT owner,object_name, object_type, status FROM dba_objects
WHERE status = 'INVALID';
71. What is the syntax to compile invalid objects manually for small no.of
objects?
Alter object objectname compile;

72. How to compile all the invalid objects in a specified schema?

EXEC DBMS_UTILITY.compile _schema (schema => ‘SCOTT’);

72. How to recompile invalid objects in the database?

Using utlrp.sql and utlprp.sql .these scripts are run after major database changes

such as upgrades or patches.these scripts are located in

$ORACLE_HOME/rdbms/admin directory.Both scripts must be run as

sys user or any user with sysdba priv.The utlrp.sql calls utlprp.sql script with a

command line parameter 0

0 - The level of parallelism is derived based on the CPU_COUNT parameter.

1 - The recompilation is run serially, one object at a time.

N - The recompilation is run in parallel with "N" number of threads.

73. When the objects will become invalid?

In a typical running application, you would not expect to see views or stored procedures become

invalid because applications typically do not change table structures or change view or stored procedure

definitions during normal execution. Changes to tables, views, or PL/SQL units typically occur when an

application is patched or upgraded using a patch script or ad-hoc DDL statements. Dependent objects might

be left invalid after a patch has been applied to change a set of referenced objects.

Eg : when we rebuild a table, the indexes on that table becomes invalid

74. What is UTLRP.SQL?


This script recompiles invalid PLSQL modules.
75. What this script does?
This script recompiles all existing invalid PL/SQL modules in a database.
This is a fairly general script that can be used at any time to recompile all existing
invalid PL/SQL modules in a database If run as one of the last steps during
migration/upgrade/downgrade this script will validate all
PL/SQL modules (i.e. procedures, functions, packages, triggers, types, views,
libraries) during the migration step itself

76. packages and package bodies gong invalid when I make schema changes. How
do I recompile invalid objects?
Here is a script to recompile invalid PL/SQL packages and package bodies
invalid.sql

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;
@run_invalid.sql

Potrebbero piacerti anche