Skip to Main Content
  • Questions
  • unable to connect using database link

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, kamal.

Asked: August 16, 2000 - 5:17 pm UTC

Last updated: February 19, 2019 - 5:59 am UTC

Version: 8.1.5

Viewed 10K+ times! This question is

You Asked

DEAR TOM,
I CREATED A DATABASE LINK ON MY LOCAL DATABASE USING THE FOLLOWING COMMANDS.
SQL> CREATE DATABASE LINK RP
2 CONNECT TO PRINCE
3 IDENTIFIED BY PRINCE
4 USING 'ORB';

Database link created.

SQL> SELECT COUNT(*) FROM DUAL@RP;
SELECT COUNT(*) FROM DUAL@RP
*
ERROR at line 1:
ORA-02085: database link RP.LPU.ST.NM.US connects to ORB

I am unable to view the data.
Pls hlp me in this matter
THANKS
KAMAL

and Tom said...



You have global names set to TRUE which means the database link has to be named after the global name of the other database.

So, you can do one of the following:

o alter session|system set global_names=false
o create the database link with the name ORB instead of RP
o rename the global name of ORB to RP

Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Database link

Vivek, October 07, 2003 - 10:50 am UTC


Tom,
I am confused while creating and using database link. So need you advise on that. I have two databases with following setting

LOCAL REMOTE
db_name mass orcl
db_domain world world
global_name true true

Now if I am creating a database link like

afm@MASS.WORLD> create database link orcl.world@albert connect to fsa identified by fsa using 'ASPECT.WORLDÂ’;

Database link created.
In one of the thread so have said add some extra stuff after @, so i have added my server name.

afm@MASS.WORLD> select count(*) from em@orcl.WORLD@albert;
select count(*) from em@orcl.WORLD@albert
*
ERROR at line 1:
ORA-02085: database link ORCL.WORLD@ALBERT connects to ORACLE.WORLD

Why its trying to connect to ORACLE.WORLD?

But if alter the session for global_name it works

afm@MASS.WORLD> alter session set global_names=false;

Session altered.

afm@MASS.WORLD> select count(*) from em@orcl.WORLD;

COUNT(*)
----------
2852

Why I need to set the flag to FALSE, when I have created the DB link same as database name?

I thought if i have created DB link with Database name then global_name parametre is not relevant.

Thanks

Vivek


Tom Kyte
October 07, 2003 - 10:55 am UTC

you need to use the GLOBAL_NAME for local and remote -- not the "db_name", the GLOBAL NAME


select * from global_name;

thats the name you want to use.

when global_name is true, the name of the db link must match the global name of the remote instance.

Still same ORA-02085 error

sadiq noorulla, December 25, 2004 - 5:14 am UTC

SQL> conn scott@unix
Enter password: *****
Connected.
SQL> select * from global_name;

GLOBAL_NAME
-------------------------------------------------------------------
RMLMYS

above is remote database global name

SQL> conn scott@rane
Enter password: *****
Connected.
SQL> select * from global_name;

GLOBAL_NAME
-------------------------------------------------------------------
ORACLE.WORLD

As you have said I have suggested above I used same name as global name

SQL> create database link RMLMYS@unixserver
  2  connect to scott
  3  identified by tiger
  4  using 'unix';

Database link created.

Then why this error

SQL> select * from dual@RMLMYS@unixserver;
select * from dual@RMLMYS@unixserver
                   *
ERROR at line 1:
ORA-02085: database link RMLMYS.WORLD@UNIXSERVER connects to RMLMYS

But after making false it is working fine 
Why I should make false
As you have suggested for vivek I have used Global name not db name

SQL> alter session set global_names=false
  2  /

Session altered.

SQL> select * from dual@RMLMYS@unixserver;

D
-
X 

Tom Kyte
December 25, 2004 - 9:11 am UTC

RMLSYS.WORLD connects to RMLMSYS

you have a domain slipped in there. you'll need to "domain" that other server.

solves ORA-02085

Linda S, May 14, 2018 - 2:40 pm UTC

great answer

Never out of date :-) Thanks Tom

A reader, February 18, 2019 - 8:35 pm UTC

Connor McDonald
February 19, 2019 - 5:59 am UTC

:-)