Q
Problem solve Get help with specific problems with your technologies, process and projects.

Connecting two database servers with two different host strings

I'm a newbie to using Oracle. I wanted to connect two database servers using Oracle 9i (running on Windows XP)...

with two different host strings. Can you give me a clue as to how to do it?

You need to configure your TNSNAMES.ORA file to point to each of your Oracle instances you want to connect to. This file is typically in your ORACLE_HOME/network/admin directory. For each database that you want to connect to, add an entry similar to the following:

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
    )
    (CONNECT_DATA = (SERVICE_NAME = ORCL)
    )
  )

You'll need to change your host, port, and service name (ORACLE_SID) to match the database that you want to connect to. This TNS alias is identified by the first line. Typically, the TNS alias is the same as the SERVICE_NAME, but that is not a hard and fast rule, especially if you want to connect to two databases that have the same ORACLE_SID. The TNS alias only has meaning to you.

So let's assume that you have created the TNS alias above. To connect to this database, fire up SQL*Plus as follows:

sqlplus /nolog
connect scott/tiger@orcl

The "@orcl" tells SQL*Plus to connect to the database identified by that TNS alias. To connect to a different database, use a different TNS alias.


This was last published in October 2004

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close