12/04/2014

How to use sqlplus to connect to Oracle database

How to use sqlplus to connect to an Oracle  on another host without modifying  own tnsnames.ora


Foremost you can export  to  TNS_ADMIN variable a path to temporary tnsnames.ora file.
like 

export  (or setenv in case csh) TNS_ADMIN=/home/orasid/tns/

The structure of file should looks like this 

local_SID =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL= TCP)(Host= hostname.network)(Port= 1521))
    (CONNECT_DATA = (SID = remote_SID))

  )


check ENV and check tnsping to database host 
example

# ENV

# tnsping local_SID

then if mentioned above check was success try to connect via SQLPLUS

#:~> sqlplus user/passwd@local_SID


Or if you don want to export any files to temporary environment you can connect to oracle  db like this 

sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))"

No comments:

Post a Comment

Popular Posts