Thursday 11 October 2012

Configure and connect to remote Oracle DB Server using SQLPlus

We have Oracle DB Server with IP 192.168.2.207 and port 1521.
You need to know: database, schema, table, user account <testuser> password <test> . After that you can concat your connection string:

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=  192.168.2.207)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TestDB)))

This connection string you'll need to add  tnsnames.ORA in file that often lay in: 

C:\Oracle\product\11.2.0\client_1\network\admin\tnsnames.ORA.

You should to give unique alias for you connection. Something like:
...
TestConneсt =
(DESCRIPTION=
  (ADDRESS =
    (PROTOCOL = TCP)(HOST =  192.168.2.207)(PORT = 1521)
  )
  (CONNECT_DATA =
    (SERVICE_NAME=TestDB)
  )
)
...

Save it. Now we can test our new connection. Open Run -> cmd in command line input command:

tnsping TestConnect

More information about keys of this command you can find at http://docs.oracle.com/cd/E19957-01/805-3808/6j3kacb36/index.html

You'll need to change password, if you make your first connection to DB. I use SQLPlus (must be installed  with Oracle client). In the command line enter:


sqlplus testuser/password@192.168.2.207/TestConnect
Password: <oldpass>
NewPassword: <newpass>

No comments:

Post a Comment