Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Reverse all db_link

$
0
0
set lines 220
set echo off
set feedb off
set termout off
set heading off
SET VERIFY off
set trimspool on
set long 32766
set longchunksize 200
col l1 format a90
col l2 format a90 newline
col l3 format a100 newline
col l6 format a200 newline word_wrapped
col l9 format a90 newline

define spoolfile=/u01/app/oracle/oraadm/tmp/reverse_all_dblinks_out.sql
spool &spoolfile

select 'select '||''''||'-- '||owner||'.'||db_link||''''||' from dual; ' l1,
       'select '||''''||'connect '||decode(owner, 'PUBLIC', 'oem', owner)||'/'||
       decode(owner, 'PUBLIC', 'n0th1ng ', sys_context('userenv', 'db_name')||owner)||''''||' from dual; ' l2,
       'select '||''''||'drop '||decode(owner, 'PUBLIC', 'PUBLIC ', '')||'database link '||db_link||';'||''''||' from dual; ' l3,
       'select dbms_metadata.get_ddl('||''''||'DB_LINK'||''''||','||
       ''''||db_link||''''||','||''''||owner||''''||') from dual; ' l6,
       'select '||''''||'/'||''''||' from dual; ' l9
from dba_db_links
order by owner, db_link
/
spool off
set termout on

@&spoolfile

set echo on
set feedb on
set heading on
SET VERIFY on

undefine spoolfile


Viewing all articles
Browse latest Browse all 1640

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>