Invalid objects
When to use it
Every day, and always after a deployment, a patch or an import.
Run this
Script: 01_find_invalid_objects.sql. Full version in Performance › Performance monitoring › Object status.
SET LINESIZE 150
SET PAGESIZE 50
COLUMN owner FORMAT A30
COLUMN object_name FORMAT A30
COLUMN object_type FORMAT A20
COLUMN last_ddl_time FORMAT A20
SELECT
owner,
object_name,
object_type,
to_char(last_ddl_time, 'YYYY-MM-DD HH24:MI:SS') AS last_ddl_time
FROM
dba_objects
WHERE
status = 'INVALID'
and owner='APPS'
ORDER BY
owner,
object_type,
object_name;
/
--exec dbms_utility.compile_schema('APPS', FALSE)
--SET SERVEROUTPUT ON;
This script filters on owner = 'APPS', the Oracle E-Business Suite schema. Change or remove that line for other databases.
Starter query for a count per schema:
SELECT owner, object_type, COUNT(*) AS invalid_objects
FROM dba_objects
WHERE status = 'INVALID'
GROUP BY owner, object_type
ORDER BY owner, object_type;
How to read the output
- A small, stable number of invalid objects can be normal in some applications. What matters is a change from yesterday.
last_ddl_timeshows when the object was last changed. A group of objects with the same recent time usually points to a deployment.- Invalid objects in
SYSorSYSTEMafter a patch need attention from a senior DBA.
What to do next
- Compare with the previous day before you do anything.
- Recompiling is usually safe but it is still a change:
recompile-invalid-objects.sql(Reference › Sessions and objects › Recompile Invalid PL/SQL Objects): identifies and recompiles invalid objects. - If objects stay invalid after a recompile, query
dba_errorsfor the reason and send it to the application team.
Risk level
READ ONLY Safe to run at any time. It only queries the data dictionary.