Wednesday, February 1, 2012

Service Vs SID in tnsnames.ora file

A service name is more flexible than a SID would be.

A database can dynamically register with a listener using one or more service names. In fact, more than one database can register with a listener using the same service name (think about a clustered environment where you have multiple instances that all are the same database under the covers).

A database on the other hand has a single SID. And a single SID goes to a single database. It is a pure 1:1 relationship.

A service is a many to many relationship.

Service names are used with dynamic registration - the data registers with the listener after it starts up. Once it does that, you can connect.


With the SID - that is more like telling the listener "I want you to connect to this specific database, I know the 'address', here you go"

With the SERVICE - you are asking the listener to put you in touch with a database that can service your request, a database that registers using that service.

That you cannot connect using the service name MYDB means your database is not registering with that listener (see the Net Admin guide for dynamic registration) or if it is registered with that listener (lsnrctl services is a command you can use to see the registered services) then it is registering with a different name.

Reference: Tom Kytes

No comments:

Post a Comment