Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> "dangling" synonyms: How do I get rid of them ?
Hello,
I have a database here that has a LOT of synonyms pointing to nowhere. I mean, say
synonym usera.tablea points to userb.tableb but user userb and/or table tableb has been dropped.
I' trying to identify all the "dangling" synonyms in my oracle instance, I taught that the simple following SQL would help me but it misses some of them:
select 'drop synonym '||s.owner||'.'||synonym_name||';'
from dba_synonyms s
where not exists(select 'x' from dba_objects t
where t.object_name=s.table_name andt.owner=s.table_owner)
Please not that I added the db_link clause because I do not want to drop synonyms that refer to remote objects (which of course I would never find on the local machine...)
Thanks