Wednesday 30 September 2015

database link dblink without tnsnames.ora on the server

Wow, another day of learning.  I guess that it all makes sense, but if you create a database link from your client, and you reference a tnsentry that you think is going to exist on the server, then it might not.  Remember database links are going to use the servers tnsnames.ora and sqlnet.ora to try and work out where to go for the data.

create database link "jde_findeva" 
connect to JDE
identified by myp@ss
using
'findeva’;

The link above needs the server tnsnames to know about findeva, however, this could be written with:

CREATE DATABASE LINK jde_findev
connect to JDE
identified by myp@ss
USING '(DESCRIPTION=(SDU=3000)(ADDRESS=(PROTOCOL=TCP)(HOST=myDBServer01)(PORT=1531))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=findeva.mydomain.com)))' ;

Basically, you’ve done a tnsping on a machine that does know about the database and ripped out everything from (DESCRIPTION onwards.  Removed the spaces and used this to create your database link.  Notice that this is also not a public link, make it private.

No comments: