Skip to content
December 31, 2012 / doganay

DROP ORPHAN SYNONYMS


How to drop orphan (referenced object does not exist) synonyms (including public ones):

select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'";' from dba_synonyms a
where not exists
(
select null from dba_objects b
where a.table_name=b.object_name
and a.table_owner=b.owner
);

Leave a comment