V$SESSION
displays session information for each current session.
Column | Datatype | Description |
|
| Session address |
|
| Session identifier |
|
| Session serial number. Used to uniquely identify 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. |
|
| Auditing session ID |
|
| Address of the process that owns the session |
|
| Oracle user identifier |
|
| Oracle username |
|
| Command in progress (last statement parsed); for a list of values. These values also appear in the |
|
| Identifier of the user who owns the migratable session; the column contents are invalid if the value is For operations using Parallel Slaves, interpret this value as a 4-byte value. The low-order 2 bytes represent the session number and the high-order bytes represent the instance ID of the query coordinator. |
|
| Address of the transaction state object |
|
| Address of the lock the session is waiting for; NULL if none |
|
| Status of the session: · · · · · |
|
| Server type: · · · · |
|
| Schema user identifier |
|
| Schema user name |
|
| Operating system client user name |
|
| Operating system client process ID |
|
| Operating system machine name |
|
| Operating system terminal name |
|
| Operating system program name |
|
| Session type |
|
| Used with |
|
| Used with |
|
| SQL identifier of the SQL statement that is currently being executed |
|
| Child number of the SQL statement that is currently being executed |
|
| Time when the execution of the SQL currently executed by this session started; NULL if |
|
| SQL execution identifier; NULL if |
|
| Used with |
|
| Used with |
|
| SQL identifier of the last SQL statement executed |
|
| Child number of the last SQL statement executed |
|
| SQL execution start of the last executed SQL statement |
|
| SQL execution identifier of the last executed SQL statement |
|
| Object ID of the top-most PL/SQL subprogram on the stack; NULL if there is no PL/SQL subprogram on the stack |
|
| Subprogram ID of the top-most PL/SQL subprogram on the stack; NULL if there is no PL/SQL subprogram on the stack |
|
| Object ID of the currently executing PL/SQL subprogram; NULL if executing SQL |
|
| Subprogram ID of the currently executing PL/SQL object; NULL if executing SQL |
|
| Name of the currently executing module as set by calling the |
|
| Hash value of the |
|
| Name of the currently executing action as set by calling the |
|
| Hash value of the |
|
| Information set by the |
|
| This contains a number that increases every time the session completes a call to the database and there has been an intervening select from a dynamic performance table. This column can be used by performance monitors to monitor statistics in the database. Each time the performance monitor looks at the database, it only needs to look at sessions that are currently active or have a higher value in this column than the highest value that the performance monitor saw the last time. All the other sessions have been idle since the last time the performance monitor looked at the database. |
|
| Object ID for the table containing the row specified in |
|
| Identifier for the datafile containing the row specified in |
|
| Identifier for the block containing the row specified in |
|
| Current row being locked. This column is valid only if the session is currently waiting for another transaction to commit and the value of |
|
| Time of logon |
|
| If the session If the session |
|
| This column has been replaced by the |
|
| Indicates whether and to what extent transparent application failover (TAF) is enabled for the session: · · · |
|
| Indicates the transparent application failover method for the session: · · · |
|
| Indicates whether the session is running in failover mode and failover has occurred ( |
|
| Name of the session's current resource consumer group |
|
| If |
|
| If |
|
| If |
|
| If queued ( |
|
| Client identifier of the session |
|
| Blocking session status: · · · · · |
|
| Instance identifier of the blocking session |
|
| Session identifier of the blocking session |
|
| A number that uniquely identifies the current or last wait (incremented for each wait) |
|
| Event number |
|
| Resource or event for which the session is waiting |
|
| Description of the first wait event parameter |
|
| First wait event parameter (in decimal) |
|
| First wait event parameter (in hexadecimal) |
|
| Description of the second wait event parameter |
|
| Second wait event parameter (in decimal) |
|
| Second wait event parameter (in hexadecimal) |
|
| Description of the third wait event parameter |
|
| Third wait event parameter (in decimal) |
|
| Third wait event parameter (in hexadecimal) |
|
| Identifier of the class of the wait event |
|
| Number of the class of the wait event |
|
| Name of the class of the wait event |
|
| If the session is currently waiting, then the value is · > · · This column has been deprecated in favor of the columns |
|
| If the session is currently waiting, then the value is the amount of time waited for the current wait. If the session is not in a wait, then the value is the amount of time since the start of the last wait. This column has been deprecated in favor of the columns |
|
| Wait state: · · · · |
|
| Amount of time waited (in microseconds). If the session is currently waiting, then the value is the time spent in the current wait. If the session is currently not in a wait, then the value is the amount of time waited in the last wait. |
|
| Value is interpreted as follows: · > · · · NULL - Session is not currently waiting |
|
| Time elapsed since the end of the last wait (in microseconds). If the session is currently in a wait, then the value is |
|
| Service name of the session |
|
| Indicates whether SQL tracing is enabled ( |
|
| Indicates whether wait tracing is enabled ( |
|
| Indicates whether bind tracing is enabled ( |
|
| Frequency at which row source statistics are dumped in the trace files for each cursor: · · · |
|
| Reserved for future use |
|
| Address of the creating process or circuit |
|
| Serial number of the creating process or circuit |
*The P1RAW
, P2RAW
, and P3RAW
columns display the same values as the P1
, P2
, and P3
columns, except that the numbers are displayed in hexadecimal.
COMMAND Column of V$SESSION and Corresponding Commands
Number | Command | Number | Command |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| | |
Note:
- The following query identifies CPU usage Per schema in a simple resource plan scenario (Metalink note 728613.1):
select sum(r.CONSUMED_CPU_TIME) "CONSUMED CPU TIME" , s.username "SCHEMA" from V$RSRC_SESSION_INFO r, v$session s where r.sid = s.sid group by username; |
- Generate sql to kill a session:
select 'alter system disconnect session '''||s.sid||','||s.serial#||''' immediate;' from V$PROCESS p, V$SESSION s where s.paddr = p.addr and s.username = upper ('&killme'); |
select 'alter system kill session '''||s.sid||','||s.serial#||''' immediate;' from V$PROCESS p, V$SESSION s where s.paddr = p.addr and s.username = upper ('&killme'); |
- List the old sessions:
select s.osuser, p.spid, s.username, s.sid, s.serial#, to_char(s.logon_time,'Dy dd Mon HH24:MI:SS') start_time, s.status, s.machine, s.MODULE from V$PROCESS p, V$SESSION s where s.paddr = p.addr and s.username is not null and s.status = 'INACTIVE' and s.logon_time <> |
- Show current users:
select s.osuser, p.spid, s.username, s.sid, s.serial#, to_char(s.logon_time,'Dy dd Mon HH24:MI:SS') start_time, s.status, s.machine, s.MODULE from V$PROCESS p,V$SESSION s where s.paddr = p.addr and s.username is not null order by logon_time,1; |
- Show the number of current commits:
select command, count(command) from V$SESSION where command = '44' group by command order by 1; |
- List stale connections:
select to_char(logon_time,'Dy dd Mon HH24:MI') logon_time, sid || ',' || serial# sid_serial, username, osuser, trunc(last_call_et/60/60) last_call, status, program, module from V$SESSION where type != 'BACKGROUND' and username is not null and trunc(last_call_et/60/60) > 1 order by 5; |
- Show how users are logging on
select program,count(program) from V$SESSION group by program order by program; |
- List current sessions and their sql statements:
select vp.username os_user, vp.spid server_pid, vs.process client_pid, vs.sid||','||vs.serial# SID_Serial, vs.terminal, vs.username oracle_username, vs.status, to_char(vs.LOGON_TIME, 'dd/mon hh:mi') logon_time, to_char(trunc(sysdate) + (vs.LAST_CALL_ET/(24*3600)), 'hh24:mi') Idle_time, vl2.sid lock_sid, to_char(trunc(sysdate) + (vl1.ctime/(24*3600)), 'hh24:mi') Wait_time from V$PROCESS vp, V$SESSION vs, V$LOCK vl1, V$LOCK vl2 where vp.addr = vs.paddr and vs.lockwait = vl1.kaddr(+) and vl1.id1=vl2.id1(+) and vl2.lmode(+)!=0 and vs.paddr not in (select paddr from V$BGPROCESS) order by 7, 9 -- Status, Idle Time |
select vs.sid||','||vs.serial# SID_Serial, vs.status, vs.module, st.sql_text from V$SESSION vs, V$SQLTEXT st where st.address = decode(vs.sql_address, hextoraw('00'), vs.prev_sql_addr, vs.sql_address) and st.hash_value = decode(vs.sql_hash_value, 0, vs.prev_hash_value, vs.sql_hash_value) and vs.paddr not in (select paddr from V$BGPROCESS) -- exclude background processes order by vs.status, vs.last_call_et, 1, st.piece |
- List current running sql statements:
SELECT u.sid, u.username, s.sql_text FROM V$SQL s, V$SESSION u WHERE s.hash_value = u.sql_hash_value AND sql_text not like '%from v$sql s, v$session u%' ORDER BY u.sid; |
- Troubleshooting enq: TX - row lock contention
--for which SQL currently is waiting to, select sid, sql_text from v$session s, v$sql q where sid in (select sid from v$session where state in ('WAITING') and wait_class != 'Idle' and event='enq: TX - row lock contention' and (q.sql_id = s.sql_id or q.sql_id = s.prev_sql_id) ); |
--The blocking session is: select blocking_session, sid, serial#, wait_class, seconds_in_wait from v$session where blocking_session is not NULL order by blocking_session; |
- find out What session has locked a PL/SQL package
select x.sid from v$session x, v$sqltext y where x.sql_address = y.address and y.sql_text like '% |
Oracle data dictionary views
Oracle dynamic performance views
Last updated: July 07, 2009 |
No comments:
Post a Comment