Database Link fails with ORA-12154 even after setting TNS_ADMIN environment variable

(Doc ID 470933.1)

Last updated on SEPTEMBER 06, 2017

Applies to:

Oracle Net Services - Version 9.0.1.0 to 11.2.0.3 [Release 9.0.1 to 11.2]
Oracle Net Services - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Oracle Net Services - Version 12.1.0.2 to 12.1.0.2 [Release 12.1]
Information in this document applies to any platform.
***Checked for relevance on 16-OCT-2013***

This problem can occur on any platform.
Oracle Server - Enterprise Edition - Version: 8i to 11g

Symptoms

When creating a dblink between two databases, if TNS_ADMIN is not set or set to $ORACLE_HOME/network/admin  selecting across the dblink works fine.  If setting  $TNS_ADMIN to a  path different from  $ORACLE_HOME/network/admin, select from dblink can fail with:

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

The workaround would be to create the dblink with a full connect descriptor instead of a TNS alias.

Here's an example:


create database link DB_TEST connect to SCOTT
identified by "password"
using '(description=(address=(protocol =TCP)
(host=myhost)(port=1521))(connect_data=(SERVICE_NAME=sid.domain)))'; 

Changes

This is likely a new database link or the environment has changed.  If $TNS_ADMIN has been set recently, this article may apply.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms