使用 oracle 数据库链接时出现错误“ORA-12154 TNS 无法解析指定的连接标识符”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10417010/
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-19 00:46:45  来源:igfitidea点击:

on using oracle database link theres an error "ORA-12154 TNS Could not resolve the connect identifier specified"

oracledatabase-link

提问by gold finger

I'm trying to define a database link on oracle 10.2 with connection identifier that throws the error in the question header. I have the connection identifier (service name) in my tnsnames.ora file. I can connect with sqlplus using this service name. no problem. This is the creation sql:

我正在尝试在 oracle 10.2 上定义一个带有在问题标题中引发错误的连接标识符的数据库链接。我的 tnsnames.ora 文件中有连接标识符(服务名称)。我可以使用此服务名称与 sqlplus 连接。没问题。这是创建sql:

create database link dev1.REGRESS.RDBMS.DEV.US.ORACLE.COM connect to user1 identified by pass1 using 'dev1';

创建数据库链接 dev1.REGRESS.RDBMS.DEV.US.ORACLE.COM 使用“dev1”连接到由 pass1 标识的用户 1;

select using the link: select * from t_users@dev1;

使用链接选择: select * from t_users@dev1;

I get: ORA-12154: TNS:could not resolve the connect identifier specified

我得到:ORA-12154:TNS:无法解析指定的连接标识符

connecting to oracle with sqlplus to the 'unidentified' service (with no problem): sqlplus user1/pass1@dev1

使用 sqlplus 连接到 oracle 到“身份不明”的服务(没有问题):sqlplus user1/pass1@dev1

I defined another link to the same database I'm woking in (loopback) - works OK.

我定义了另一个指向我正在工作的同一个数据库的链接(环回) - 工作正常。

I read and tried anything I could find about the subject but did not solve this.

我阅读并尝试了我能找到的关于该主题的任何内容,但没有解决这个问题。

Any suggestions?

有什么建议?

回答by Phil

Try:

尝试:

create database link dev1 connect to user1 identified by pass1 using 'dev1';

Also note that a tnsnames.ora entry for dev1has to exist on the database server that you're linking from.

另请注意,dev1您要链接的数据库服务器上必须存在tnsnames.ora 条目。