oracle创建DBLINK
1.查看Global_name参数
show parameter global_name;
该参数为true时,你在本地建立的DBLINK的名称必须和远程的Global_name一致才行。
2.查看远程数据徊是否支持高级复制功能
select * from v$option where PARAMETER='Advanced replication';
如何返回值为True,那么就是支持,否则就是不支持。在两个数据库中都是检查是否支持才行。
3.连接服务器配置主机tnsname.ora
YCMAINDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.251.194)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ycmaindg)
)
)
4.授予ycheng用户权限:
SYS@ENMOEDU > grant create public database link,create database link to ycheng;
Grant succeeded.
5.创建DBLINK(用户名密码和生产一致)
SYS@ENMOEDU > conn ycheng/oracle
Connected.
Grant succeeded.
5.创建DBLINK(用户名密码和生产一致)
SYS@ENMOEDU > conn ycheng/oracle
Connected.
create database link ycmainlink
connect to ycheng
identified by "******"
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL =TCP)(HOST = 172.16.251.194)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = YCMAINDG)
)
)';
6.测试
SELECT table_name FROM all_tables@ycmainlink WHERE owner = upper('YCHENG');