Wednesday, February 9, 2011

Connecting to database from remote client

  • Start listener on server machine
  • Install adminstrative client s/w on the client machine and add server name in tnsname.ora in client machine
  •  Verify on client machine:
    • tnsping <servicename>
    • sqlplus tpcc/tpcc@bench (where tpcc is the username and bench is the service name)
    • setenv TWO_TASK bench
    • sqlplus tpcc/tpcc (you should get the prompt)
    •  
  • What is the use of TWO_TASK environment variable ?
If you are in a Unix environment, you can normally set 2 environment variables:
  • ORACLE_HOME
  • ORACLE_SID
that will connect you to a local database identified by that home and sid. If you wanted
to be able to connect to a remote database or a database on that machine via SQLNet, you
can also set:
  •  TWO_TASK = <tnsconnect string> 
The setting of TWO_TASK overrides the ORACLE_SID when set. You will not connecting to a
local database with two_task but rather using sqlnet to connect to a remote database.
So, instead of: 
I can: 
$ setenv TWO_TASK some_db
$ sqlplus scott/tiger
and the @some_db is implied.

No comments:

Post a Comment