Abhijit
Abhijit

Reputation: 63737

How does a local database client connect with a server without a listener service

How does a database client connects to a database server on a local system without tns entry?

I was in the impression that a client always connects to a database server via the tcp/ip channel. So tnsnames should reflect the tns entries and a listener service should run on the server via which the client can establish a connection.

In case, the database server is running locally, today I realized, it is possible to connect to the database without a listener service by just specifying the SID as follows

SET ORACLE_SID=<SID>
sqlplus username/password

Now my question is through what communication channel does the client communicates with the server?

Upvotes: 2

Views: 3099

Answers (1)

Alex Poole
Alex Poole

Reputation: 191275

It uses a 'bequeath' connection that doesn't go through the listener. From the Net Services admin guide:

If the client and database exist on the same computer, then a client connection can be passed directly to a dedicated server process without going through the listener. This is known as a bequeath protocol. The application initiating the session spawns a dedicated server process for the connection request. This happens automatically if the application used to start the database is on the same computer as the database.

So if you don't specify a connect string, SQL*Plus (or SQL*Loader, or any local native application) spawns a dedicated process - assuming your ORACLE_SID is set, of course.

Dedicated processes spawned by the listener are also bequeath - the term comes from the forked process inheriting the connection, I believe. You can see the difference if you look at the ps output on a Unix system; when you're connected without using TNS you'll see a dedicated process called oracle<SID> with (PROTOCOL=beq) and (LOCAL=YES); if you have a dedicated process that has gone through the listener it will have (LOCAL=NO) instead.

If you're only connecting locally then you don't need to have a listener running at all. That's somewhat unusual of course, and can cause some confusion when someone assumes the listener exists and is up because they connect locally...

Upvotes: 1

Related Questions