Wednesday, August 6, 2008

How tnsnames.ora and sqlnet.ora file work together?

I would like to bring an article which explains how useful sqlnet and tnsnames files are and how they work together.

The default domain in the Sqlnet file is used for a SCENARIO purpose only.

SCENARIO 1:

in tnsnames.ora

dba.domain = (....)

in sqlnet.ora file

names.default_domain = domain


So, in sqlplus log screen, the following can be typed in: hr/hr@dba

Note the fully qualified dbadomain would not be typed in, because it will be automatically appended to the end of the connect string specified.

SCENARIO 2:

in tnsnames.ora

dba.domain = (....)

SCENARIO.NW.NOS.ORALCE.COM = (....)

in sqlnet.ora file

names.default_domain = domain

What would happen in the SCENARIO where multiple domain have been defined in the tnsnames.ora but with only one sqlnet.ora? Just remember, the key is what is defined in the TNSNAMES.ORA file, sqlnet.ora is for convenience.

The entire connect string can be typed in.

In sqlplus log screen, just type in :

hr/hr@test
<--- should again work

hr/hr@test.domain
<--- should again work

hr/hr@SCENARIO
<--- should *NOT* work, because in fact it will be SCENARIO.domain

hr/hr@SCENARIO.NW.NOS.ORALCE.COM
<--- should work

What
is being said is that if the domain is added after the name when loginning as defined in the tnsnames.ora file, then don\'t use the default domain that is defined in the sqlnet.ora file.

SCENARIO
3:

In
fact a sqlnet.ora file is not really needed for the purposes of login

E.g.,
in tnsnames.ora

test
= (....) <--- note here, no domain

SCENARIO.NW.NOS.BOEING.COM
= (....)

no sqlnet.ora file exists anywhere.

In
sqlplus log screen, just type in :

hr/hr@test
<--- should again work

hr/hr@SCENARIO.NW.NOS.BOEING.COM
<--- should work

hr/hr@SCENARIO
<--- should *NOT* work

hr/hr@test.domain
<--- should *NOT* work

No comments: