How SID is different from Service name in Oracle tnsnames.ora
Asked Answered
S

5

201

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

Sweetening answered 4/9, 2008 at 14:26 Comment(1)
How to find our service name when I have SID name?Motoneuron
S
169

Quote by @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 be the 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.

Sewell answered 4/9, 2008 at 14:39 Comment(5)
So, in your example, there might be SIDs Sales1, Sales2, and Sales3, all of which are available via service name Sales?Hydracid
I think the opposite is the case: You have one SID that is available as many services. You could then take one of the services, and point it at a different SID/database.Trimurti
Can we have the Oracle SID name same as the TNS name? Will it be a problem?Canister
@user2441441: Going by the explanation Matthew has given, I think you are right in the assumption in that there can be multiple SIDs and once Service that abstracts all the SIDsSibeal
Both are correct, according to docs.oracle.com/cd/B19306_01/network.102/b14212/concepts.htm, there could be: Figure 3-2 Multiple Services Associated with One Database, and Figure 3-4 Multiple Instances Associated with a DatabaseEngelhart
C
28

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 instance, ServiceName = the alias used when connecting

Cyma answered 4/9, 2008 at 14:34 Comment(2)
I'm confused. Shouldn't it be that in RAC, you will have different "INSTANCE_NAME" for each instance? And one SERVICE_NAME may be associated with several instances?Cobwebby
I think we should avoid saying 'Instance/database'. We have established that instance and database are different. Instance is the oracle program running in memory. Database is the actual files that contain the data. An analogy would be Microsoft Word. The Word application is the "Instance". The actual document that you open is the "database"Vining
P
28

I know this is ancient however when dealing with finicky tools, uses, users or symptoms re: sid & service naming one can add a little flex to your tnsnames entries as like:

mySID, mySID.whereever.com =
(DESCRIPTION =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myHostname)(PORT = 1521))
  )
  (CONNECT_DATA =
    (SERVICE_NAME = mySID.whereever.com)
    (SID = mySID)
    (SERVER = DEDICATED)
  )
)

I just thought I'd leave this here as it's mildly relevant to the question and can be helpful when attempting to weave around some less than clear idiosyncrasies of oracle networking.

Pyrex answered 19/5, 2015 at 13:36 Comment(0)
P
7

what is a SID and Service name

please look into oracle's documentation at https://docs.oracle.com/cd/B19306_01/network.102/b14212/concepts.htm

In case if the above link is not accessable in future, At the time time of writing this answer, the above link will direct you to, "Database Service and Database Instance Identification" topic in Connectivity Concepts chapter of "Database Net Services Administrator's Guide". This guide is published by oracle as part of "Oracle Database Online Documentation, 10g Release 2 (10.2)"

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

Consider below mapping in a RAC Environment,

SID      SERVICE_NAME
bob1    bob
bob2    bob
bob3    bob
bob4    bob

if load balancing is configured, the listener will 'balance' the workload across all four SIDs. Even if load balancing is configured, you can connect to bob1 all the time if you want to by using the SID instead of SERVICE_NAME.

Please refer, https://community.oracle.com/thread/4049517

Pappano answered 9/1, 2018 at 12:31 Comment(0)
C
1

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.

Calamity answered 16/4, 2010 at 13:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.