Skip to content

Instantly share code, notes, and snippets.

@willis7
Last active December 21, 2015 14:19
Show Gist options
  • Save willis7/6318722 to your computer and use it in GitHub Desktop.
Save willis7/6318722 to your computer and use it in GitHub Desktop.
Recompile invalid objects in an Oracle database
set head off
set feedback off
spool compile.lis
select 'alter package '|| owner ||'.'||object_name||' compile;'
from all_objects
where object_type like 'PACKAGE'
and status = 'INVALID'
/
select 'alter package '|| owner ||'.'||object_name||' compile body;'
from all_objects
where object_type like 'PACKAGE BODY'
and status = 'INVALID'
/
select 'alter trigger '|| owner ||'.'||object_name||' compile;'
from all_objects
where object_type like 'TRIGGER'
and status = 'INVALID'
/
select 'alter view '|| owner ||'.'||object_name||' compile;'
from all_objects
where object_type like 'VIEW'
and status = 'INVALID'
/
select 'alter materialized view '|| owner ||'.'||object_name||' compile;'
from all_objects
where object_type like 'MATERIALIZED VIEW'
and status = 'INVALID'
/
select 'alter type '|| owner || '.'||object_name||' compile;'
from all_objects
where object_type like 'TYPE'
and status = 'INVALID'
/
select 'alter procedure '|| owner || '.'||object_name||' compile;'
from all_objects
where object_type like 'PROCEDURE'
and status = 'INVALID'
/
select 'alter function '|| owner || '.'||object_name||' compile;'
from all_objects
where object_type like 'FUNCTION'
and status = 'INVALID'
/
spool off
set head on
set feedback on
@compile.lis
set lines 2000
select substr(object_name,1,30) object_name, owner, object_type, status, timestamp from all_objects where status !='VALID';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment