这篇文章主要介绍“创建dblink的方法有哪些”,在日常操作中,相信很多人在创建dblink的方法有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”创建dblink的方法有哪些”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
结合平日的经验,现总结几种创建dblink的方法:
(1) 最常用的方法:
create database link dblink_120
connect to zhan identified by "zhan"
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.120)(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = bond)))';
(2) 利用tns的方法:
首先我们在服务端添加tns,注意这里一定是目标库服务端的tnsnames.ora下面添加,不是在客户端的tnsnames.ora下添加,否则会报错。
db_110 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
db_120 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.120)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bond)
)
)
然后再创建dblink:
create database link dblink_120 connect to zhan identified by "zhan" using 'db_120';
(3) 利用host:port/sid的方式:
create database link dblink_120 connect to zhan identified by "zhan" using '192.168.50.120:1521/bond';
删除dblink方法:
drop database link dblink_120;
到此,关于“创建dblink的方法有哪些”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!