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
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
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
February 19, 2019 - 5:59 am UTC
:-)