oracle dblink脚本备忘

    建立oracle dblink脚本备忘录:

/*建立dblink*/
create database link zhjs_app
connect to zhjs_app identified by "zhjsapp123"
using 
'(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.148.188)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = zhjsapp)
    )
)';
/*解释*/
1、create database link zhjs_app中的zhjs_app为我们建立dblink的名字,根据需要自定
2、connect to zhjs_app identified by "zhjsapp123"用账号zhjs_app/zhjsapp123访问我们的dblink数据库,该数据库被using字句描述
3、using 
'(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.148.188)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = zhjsapp)
    )
)';
描述我们要dblink到数据库,该信息形式可以再oracle的配置文件tnsnames.ora中获取,如我的${ORACLE_HOME}/ora92/network/admin/tnsnames.ora
/*测试是否建立成功*/
select 8 from dual@zhjs_app
select * from user_objects where object_type = 'DATABASE LINK'
select * from user_objects where object_type='DATABASE LINK'
/*删除dblink*/
drop database link zhjs_app
 

 

你可能感兴趣的:(oracle,脚本)