views:

37946

answers:

4

Why do I need two of them? When I have to use one or another?

+1  A: 

Please see: http://www.sap-img.com/oracle-database/finding-oracle-sid-of-a-database.htm

What is the difference between Oracle SIDs and Oracle SERVICE NAMES. One config tool looks for SERVICE NAME and then the next looks for SIDs! What's going on?!

Oracle SID is the unique name that uniquely identifies your instance/database where as Service name is the TNS alias that you give when you remotely connect to your database and this Service name is recorded in Tnsnames.ora file on your clients and it can be the same as SID and you can also give it any other name you want.

SERVICE_NAME is the new feature from oracle 8i onwards in which database can register itself with listener. If database is registered with listener in this way then you can use SERVICE_NAME parameter in tnsnames.ora otherwise - use SID in tnsnames.ora.

Also if you have OPS (RAC) you will have different SERVICE_NAME for each instance.

SERVICE_NAMES specifies one or more names for the database service to which this instance connects. You can specify multiple services names in order to distinguish among different uses of the same database. For example:

SERVICE_NAMES = sales.acme.com, widgetsales.acme.com

You can also use service names to identify a single service that is available from two different databases through the use of replication.

In an Oracle Parallel Server environment, you must set this parameter for every instance.

In short: SID = the unique name of your DB, ServiceName = the alias used when connecting

DAC
+2  A: 

The SID is the local name of the database on your system, and the Service Name is the name of the system to the outside world.

For example, you might have have a staging database and a production database with the same SID but referenced with 2 different service names:

STAGE.WORLD =
 (DESCRIPTION =
   (ADDRESS =
      (PROTOCOL = TCP) 
      (PORT = 1521)
      (HOST = LITTLECOMPUTER.ACME.ORG)
   )
   (CONNECT_DATA = (SID = MYSID))
)
PROD.WORLD =
 (DESCRIPTION =
   (ADDRESS =
      (PROTOCOL = TCP) 
      (PORT = 1521)
      (HOST = BIGCOMPUTER.ACME.ORG)
   )
   (CONNECT_DATA = (SID = MYSID))
)
Nick Pierpoint
+8  A: 

@DAC

In short: SID = the unique name of your DB, ServiceName = the alias used when connecting

Not strictly true.. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to the be files.

Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings.

Matthew Watson
A: 

As per Oracle Glossary : SID is a unique name for an Oracle database instance. ---> To switch between Oracle databases, users must specify the desired SID <---. The SID is included in the CONNECT DATA parts of the connect descriptors in a TNSNAMES.ORA file, and in the definition of the network listener in the LISTENER.ORA file. Also known as System ID. Oracle Service Name may be anything descriptive like "MyOracleServiceORCL". In Windows, You can your Service Name running as a service under Windows Services. You should use SID in TNSNAMES.ORA as a better approach.

Ashish