2014년 3월 23일 일요일

존재하지 않는 Object를 참조하는 동의어(Synonym) 삭제하는 SQL ,[오라클/ORACLE교육/오라클강좌/구로디지털단지오라클/실무오라클교육/재직자ORACLE교육]

존재하지 않는 Object를 참조하는 동의어(Synonym) 삭제하는 SQL ,[오라클/ORACLE교육/오라클강좌/구로디지털단지오라클/실무오라클교육/재직자ORACLE교육]

===============================================================

rem
rem  Generate DDL to drop phantom synonyms in your database
rem  Excludes SYS and SYSTEM users
rem

spool dr_ph_syn.sql
set pages 0 feed off
select 'drop '||decode(owner,'PUBLIC',' public ',null)||
      'synonym '||
      decode(owner,'PUBLIC',null,owner||'.')||
      synonym_name||';'
from dba_synonyms s
where owner not in('SYSTEM','SYS')
      and
      db_link is null
      and
      not exists(select 1 from all_objects o
                    where object_type
                    in('TABLE','VIEW','SYNONYM',
                    'SEQUENCE','PROCEDURE',
                    'PACKAGE','FUNCTION')
      and
      s.table_owner=o.owner
      and
      s.table_name=o.object_name);

댓글 없음:

댓글 쓰기