본문 바로가기

DBMS/Oracle

[Oracle] 고아가 되어버린 Synonym 찾기

 

고아가 되어버린 Synonym 찾기

 

특정 테이블에 대한 시노님을 생성한 후 테이블을 삭제하더라도 시노님은 함께 삭제되지 않는다.

이렇든 불필요한 시노님이 많이 생성될 가능성이 있는데 이런 불필요한 시노님을 찾아보자.

 

 select 'drop synonym '|| owner ||'.'|| synonym_name ||';', s.* 

 from dba_synonyms s 

 where table_owner not in ('SYS', 'SYSTEM')

 and db_link is NULL 

 and table_name not in

     (select object_name

      from dba_objects o

      where o.object_name = s.table_name

      and o.owner = s.table_owner

      and o.object_type not like '%SYNONYM%')

 order by owner asc;

 

 

출처 : http://codejob.co.kr/code/view/116/

 

'DBMS > Oracle' 카테고리의 다른 글

[Oracle] 오라클 데이터베이스 시작  (0) 2013.03.17
[Oracle] DECODE 함수  (0) 2013.02.21
[Oracle] 오라클 정보 보기 View  (0) 2013.01.22
[Oracle] Redo Log File 미러링  (0) 2012.12.26
[Oracle] Controlfile 다중화  (0) 2012.12.26