How to connect SQLPlus without tnsnames.ora entry

In some weird companies, like the one am working, will restrict many things in our machine which will reduce the productivity. Recently I was trying to add a new entry in tnsnames when our database server got changed. And hell, I was not having rights to change the tnsnames file in my local machine!!! WTF!!! At the end of day I need to run one sqlplus command from the command prompt. SQLPlus needs an entry in the TNS Names file in order to work. Then I found out an way to execute the command by directly giving the connection string in the sqlplus command itself. Like this :

sqlplus username/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost.mydomain)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=servicename)))

BINGO! It works as hell. Please remember that there shouldn’t be any space in the connection string, also no carriage return (which might happen if you are copying the string from the tnsnames file.

Thats it guys. Happy Coding. đŸ™‚


Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: