Home » SQL & PL/SQL » SQL & PL/SQL » Relation between Connection and Session
Relation between Connection and Session [message #9630] Tue, 25 November 2003 03:20 Go to next message
Cheeku
Messages: 17
Registered: November 2003
Junior Member
Hi All,
Can Anybody explain the relation between connection and Session. Do i have multiple connections for a single session. If i have started multiple sessions for a user then whatever are uncommited changes for one session available to other user session.
Early replies will be appreciated.
Re: Relation between Connection and Session [message #9635 is a reply to message #9630] Tue, 25 November 2003 10:30 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
A connection and a session are basically the same thing. A session has just one connection. If you have multiple sessions for a user, uncommitted changes in one session are not visible to the other sessions of that user.

With pooled connections, users will grab a connection that already exists and use it for some duration, then when they are done it is released for use by another user, but there is still one session per connection.
Re: Relation between Connection and Session [message #9638 is a reply to message #9630] Tue, 25 November 2003 13:50 Go to previous messageGo to next message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
Connection and Session are not the same thing.

Here's an extract from the documentation :
----------------------------------------------

Connection and session are closely related to user process but are very different in meaning.

A connection is a communication pathway between a user process and an Oracle instance. A communication pathway is established using available interprocess communication mechanisms (on a computer that runs both the user process and Oracle) or network software (when different computers run the database application and Oracle, and communicate through a network).

A session is a specific connection of a user to an Oracle instance through a user process. For example, when a user starts SQL*Plus, the user must provide a valid username and password, and then a session is established for that user. A session lasts from the time the user connects until the time the user disconnects or exits the database application.

Multiple sessions can be created and exist concurrently for a single Oracle user using the same username. For example, a user with the username/password of SCOTT/TIGER can connect to the same Oracle instance several times.

In configurations without the shared server, Oracle creates a server process on behalf of each user session. However, with the shared server, many user sessions can share a single server process.
-----------------------------------

Basically a Connection is a circuit (ie network connection) between the client program and the Server.You need a connection to get the session. But you may not have a session , even if you are 'connected' .

For eg)
DEV08@samgdeab06:/ora1/oracle/dbadmin>sqlplus /nolog

SQL*Plus: Release 9.0.1.4.0 - Production on Tue Nov 25 15:50:31 2003

(c) Copyright 2001 Oracle Corporation. All rights reserved.

SQL> -- Now I have a connection (ie circuit) , but I dont have a session yet.
SQL> connect thiru
Enter password:
Connected.
SQL> -- Now I have a session ie) I can see this in v$session
SQL>
Re: Relation between Connection and Session [message #9639 is a reply to message #9638] Tue, 25 November 2003 15:03 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
I said they were "basically" the same thing. The original question dealt with the relationship between the number of sessions and connections. I wasn't attempting to provide an in-depth technical definition of the two.

Since you often seem to contradict certain postings, I will say that a response containing the phrase "interprocess communication mechanisms" is just a bit over the top for someone asking if they can have multiple connections for a single session.
Re: Relation between Connection and Session [message #9641 is a reply to message #9639] Tue, 25 November 2003 16:45 Go to previous messageGo to next message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
I wasnt providing in-depth technical definition either,just quoting the documentation.

I said they are not the same things ,thats all . There may not be 1:1 relationship between 'connection' and 'session' always.
We dont want to over simplify things ,that could raise myths. There are already too many out there.

Cheers
Re: Relation between Connection and Session [message #9656 is a reply to message #9641] Wed, 26 November 2003 21:41 Go to previous messageGo to next message
Cheeku
Messages: 17
Registered: November 2003
Junior Member
Hi Todd and Thiru,
Thanks a lot to oth of you..for the answer..i kind of got the concept....
..Cheers...
Re: Relation between Connection and Session [message #10461 is a reply to message #9638] Fri, 23 January 2004 14:50 Go to previous message
Jim Meyer
Messages: 1
Registered: January 2004
Junior Member
How does this pertain to situations where my 2nd connection (identical to first), creates more than 1 additional session? In fact, I see 4 more created for a second connection, before any queries performed(!)

I understand this difference between the two concepts as you described, but I'm interested in a correlation between my connection statements being executed, and my DB registering them precisely. Perhaps there isn't one?
Previous Topic: Logging the Exceptions to a Table or to a Text File
Next Topic: how to get database name
Goto Forum:
  


Current Time: Fri Apr 26 19:27:08 CDT 2024