Monday, January 30, 2012

Connecting to database without TNS entry

Situations might arise that database TNS entry isn't added on client side, but you might have the entry details with you. Here is how you can connect to the database even if you don't have TNS file updated with connection details.

sqlplus username/password@'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=linux01)(Port=1521))(CONNECT_DATA=(SID=test_db)))'

Similarly, a database link can be created without a TNS entry. Just mention the parameters and thats it.
CREATE  DATABASE LINK "TEST"  CONNECT TO "TEST_USER" IDENTIFIED BY "********"      USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=linux01)(Port=1521))(CONNECT_DATA=(SID=test_db)))'

Isn't it handy :)

No comments: