oracle 如何使用dblink连接两个Oracle数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2406747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:09:33  来源:igfitidea点击:

How to connect to two databases of Oracle using dblink

oracledblink

提问by KASHIFAMAN

I am tring to use db link for that I have first change the name of both databases to sol1(remote) and sol3(local) then I create a db link

我正在尝试使用 db 链接,因为我首先将两个数据库的名称更改为 sol1(remote) 和 sol3(local) 然后我创建了一个 db 链接

On sol3

在 sol3 上

CREATE DATABASE LINK SOL1.SWORLD
CONNECT TO TEST IDENTIFIED BY TEST USING SOL1;

LINK CREATED
ON SQL /> SELECT *  FROM [email protected]

Message:

信息:

SQL COULD NOT RESOLVE THE SERVICE NAME

SQL 无法解析服务名称

Then I dropped the database link and create a link from Oracle enterprise schema manager I create a public link of fixed user. After login and password, I add the name in service tab as sol1

然后我删除了数据库链接并从 Oracle 企业模式管理器创建了一个链接我创建了一个固定用户的公共链接。登录和密码后,我在服务选项卡中添加名称为sol1

When I test the connection massage appears

当我测试连接消息时出现

Link is not active

链接无效

回答by wadesworld

I believe this is the source of your problem:

我相信这是您问题的根源:

SQL COULD NOT RESOLVE THE SERVICE NAME

SQL 无法解析服务名称

This indicates that SOL1 is not in tnsnames.ora, the entry is invalid or some network connectively issue is preventing Oracle from turning the service name into an address.

这表明 SOL1 不在 tnsnames.ora 中,条目无效或某些网络连接问题阻止 Oracle 将服务名称转换为地址。

回答by ati

Make sure you have the entries in your tnsnames file.

确保您的 tnsnames 文件中有条目。

NAME (DESCRIPTION (ADDRESS_LIST (ADDRESS = (PROTOCOL = TCP 
)(HOST = host)(PORT = 1521)) 
) 
(CONNECT_DATA (SERVICE_NAME = NAME) 
) 
) 

You can now create your link in either direction.

您现在可以在任一方向创建链接。

create public database link "link name" 
connect to schemaname 
identified by " " 
using 'servicename(from tnsnames entry) 
; 

Your link could be private also.

您的链接也可以是私人的。