Question

I normally connect to my Oracle database at work using a connection string. Other then the obvious answer of asking the DBA what it is, using SQL Developer or some other tool can I find out what the tns listener name is. This is an excerpt from a config file in .net where i use to connect:

DATA SOURCE=myURL:port/servicename;PASSWORD=password

Was it helpful?

Solution

The instance's TNS name would be defined in the tnsnames.ora file on your system. When you bust that file open, you'll see something like...

MyOracleInstanceTNSName =
 (DESCRIPTION = 
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.0)(PORT = 1521))
   )
 (CONNECT_DATA =
   (SERVICE_NAME = ORA12)
 )
)

The instance name (defined in the file) is really arbitrary; meaning, you can name it whatever you want. So, in the example above, I named it MyOracleInstanceTNSName, but I could've named it something else.

In the professional world, we typically use the same name across hosts, but that's a convention. This way as we share scripts or talk about instances, we're using the same name. That's a while lot easier than remembering that Bob's "foobar" instance is the same as your "bigSexy" instance.

You can find this file in ${ORACLE_HOME}/network/admin on most systems. You should be able to find (or define) the tnsname for the instance you're using there.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top