Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, richard.

Asked: July 31, 2004 - 5:17 pm UTC

Last updated: August 03, 2004 - 3:23 pm UTC

Version: 9.2.0

Viewed 1000+ times

You Asked

Hi Tom,

In order to kill a session one needs to supply both the
sid and serial# from v$session as in.

alter system kill session '&sid, &serial#'

However all of the other v$ objects, e.g. v$sesstat, v$session_wait, v$lock etc. refer only to the sid. Thus it appears that the sid
uniquely identifies a session. Indeed, I don't believe I've ever seen more than one serial# corresponding to a sid in v$session. If this is so what is the purpose of the serial# in the kill directive, and more generally in v$session?

Moreover, now that we are on the subject of sessions, how does one create a session without actually creating a connection? Are there Pro*c or oci constructs for creating sessions within a connection?

Thanks,

Richard


and Tom said...

from the reference guide:


Session serial number. Used to identify uniquely a session's objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID.



sids (the session identifier) are used and reused over and over again. the serial# changes for them as sessions are created and destroyed. just trying to make sure you kill the thing you intended to kill.


Yes, you use OCI calls to create

a) a connection
b) within the connection, a session or sessions.


sqlplus does this when you enable autotrace statistics (so the act of querying the v$ tables doesn't affect your current sessions statistics)

forms does this to debug.

java connection pooling does this for n-tier proxy authentication.



Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

richard gostanian, August 01, 2004 - 2:40 pm UTC

Thanks for clarifying something that's bothered me for a long time.

Richard

Robert, August 03, 2004 - 3:23 pm UTC