Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commandline to modify tnsnames.ora [closed]

Is there a command line utility to modify the tnsnames.ora file for the oracle client?

[EDIT] I'm looking for something similar to odbcconf.exe (for editing ODBC connection on windows) to modify the tnsnames.ora file.

[EDIT2] I'm using MSBUILD from my automated build script. The MSBuild Community Tasks Project has an AddTnsName task that fits exactly what I need. My googling skillz must be weak. I should have been searching for MSBuild and tnsnames.ora instead of command line tnsnames.ora. However, it does surprise me that Oracle does not supply a command line utility like odbcconf for tnsnames.ora.

like image 636
Aaron Carlson Avatar asked Jan 22 '23 23:01

Aaron Carlson


2 Answers

You can provide the whole TNS string as the connection parameter:

sqlplus "scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=MYSERVICE)))"

Alternatively, if your client supports EasyConnect syntax, you can go just this:

sqlplus scott/tiger@//127.0.0.1/MYSERVICE
like image 166
Quassnoi Avatar answered Jan 31 '23 04:01

Quassnoi


IMO, this file is best maintained with an editor, but there is a Net Configuration Assistant GUI that will lead you through the steps to create one.

[Edit] I see from your additional comments now that you're looking for a scriptable way to add entries, and the direct answer to your question is no, there's no Oracle utility to do this. You'll have to come up with some cat|sed|awk solution on your own.

like image 33
dpbradley Avatar answered Jan 31 '23 05:01

dpbradley