Backup scripts for database links

Source: Internet
Author: User
Tags chr readable backup

This tip is comes from Galina Petrenko, Sr. IT Specialist, TPAs Systems Development, at Towers, Perrin, Voorhees.

Description:this script produces readable output (backup) for database links in the database. It can be used in the restore/recovery process. Note This passwords for database links are also spooled in a readable format.

col NAME new_value DB_NAME
select name from sys.v_$database;
set lines 80
col TEXT for a70
spool &DB_NAME..DB_LINKS.lst
select
'--'
||CHR(10)
||'-- Owner is ' || U.NAME
||CHR(10)
||'-- DB Link is'|| L.NAME
||CHR(10)
||'--'
||CHR(10)
||'create '||DECODE(U.NAME,'PUBLIC','public')||' database link '
||CHR(10)
||DECODE(U.NAME,'PUBLIC',Null, U.NAME||'.')|| L.NAME
||chr(10)
||'connect to ' || L.USERID || ' identified by
'''||L.PASSWORD||''' using ''' || L.host || ''''
||chr(10)||';'
TEXT
from sys.link$ L,
sys.user$ U
where L.OWNER# = U.USER#
;
spool off

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.