Friday, January 16, 2026

Compile invalid objects

 script generate compile invalid object in oracle database

SELECT owner, COUNT(*) FROM dba_objects WHERE status = ‘INVALID’ GROUP BY owner;

Compile by utlrp.sql scrip t

@?/rdbms/admin/utlrp.sql Or

EXEC UTL_RECOMP.recomp_parallel(4, ‘REPORT’); Or

you can generate scripts for specific object name

select ‘alter package ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’PACKAGE’ and status=’INVALID’;

select ‘alter package ‘||owner||’.’||object_name||’ compile body;’ from dba_objects where object_type=’PACKAGE BODY’ and status=’INVALID’;

select ‘alter synonym ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’SYNONYM’ and status=’INVALID’;

select ‘alter public synonym ‘||object_name||’ compile;’ from dba_objects where object_type=’SYNONYM’ and status=’INVALID’;

select ‘alter trigger ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’TRIGGER’ and status=’INVALID’;

select ‘alter view ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’VIEW’ and status=’INVALID’;

select ‘alter PROCEDURE ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’PROCEDURE’ and status=’INVALID’;

select ‘alter type ‘||owner||’.’||object_name||’ compile;’ from dba_objects where object_type=’TYPE BODY’ and status=’INVALID’;

No comments:

Post a Comment