How to access Oracle table using sqlplus

Hi,

I want to use sqlplus from server1

sqlplus usr1/pass1@dns1

and I want to connect to an Oracle database from a server2.

Unfortunately the database was created on the server1 and on server2.

So when I use the command just like that...it connects to the database from the server2.

Is there a way to connect to the database found on the server2?

thank you in advance for your answers

Your request isn't clear. I've understood that you have two servers, server1 and server2. On both of them there's installed an Oracle Database Server.

Regardless of the server from which you are invoking sqlplus, the destination database is determined by the last part of the connect string, that is "@dns1".

This alias is translated into four pieces of information:

  • Destination address of the remote server
  • Destination port (default: 1521)
  • Protocol (usually TCP)
  • Service Name or SID of the remote database

Assuming you're using local naming method, all these informations are stored in a file called "tnsnames.ora", that by default resides in "$ORACLE_HOME/network/admin" of the server from which you are invoking sqlplus.

Look into it and search for the entry called "dns1": here you can verify which is the real destination db server you're connecting to.

If you need to connect to the other server, you need another entry in this file, pointing to the second destination server.

I wasn't sure about my guess and I wanted another opinion. Thank you very much for your answer.