Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Sessions 

Oracle Database Tips by Donald Burleson


Finding and killing locked sessions in Oracle

Because of Oracles internal locking, there are times when it is useful to be able to locate and kill Oracle sessions that are locking database resources.  For complete details and scripts, see my book "Oracle Tuning: The Definitive Reference".

First, here is a script to display details about all sessions within Oracle.


--**************************************************************

-- session.sql © 2002 by Donald K. Burleson

--**************************************************************

rem session.sql - displays all connected sessions

set echo off;

set termout on;

set linesize 80;

set pagesize 60;

set newpage 0;

select

rpad(c.name||':',11)||rpad(' current logons='||

(to_number(b.sessions_current)),20)||'cumulative logons='||

rpad(substr(a.value,1,10),10)||'highwater mark='||

b.sessions_highwater Information

from

v$sysstat a,

v$license b,

v$database c

where

a.name = 'logons cumulative'

;

ttitle "dbname Database|UNIX/Oracle Sessions";

set heading off;

select 'Sessions on database '||substr(name,1,8) from v$database;

set heading on;

select

substr(a.spid,1,9) pid,

substr(b.sid,1,5) sid,

substr(b.serial#,1,5) ser#,

substr(b.machine,1,6) box,

substr(b.username,1,10) username,

substr(b.osuser,1,8) os_user,

substr(b.program,1,30) program

from

v$session b,

v$process a

where

b.paddr = a.addr

and

type='USER'

order by

spid;

ttitle off;

set heading off;

select 'To kill, enter SQLPLUS> ALTER SYSTEM KILL SESSION',

''''||'SID, SER#'||''''||';' from dual;

spool off;

Tue Mar 19 page 11

dbname Database

UNIX/Oracle Sessions

PID SID SER# BOX USERNAME OS_USER PROGRAM

--------- ----- ----- ------ ---------- -------- -------------------------

6230 51 251 MWC\CO APPS TEilers S:\ORANT\BIN\F50RUN32.EXE

6233 69 2729 MWC\CO APPS TEilers S:\ORANT\BIN\R30RBE32.exe

6823 75 661 corp-h APPS applmgr f45runm@corp-hp1 (TNS V1-V3)

6823 85 317 corp-h APPS applmgr

779 122 1307 corp-h APPS applmgr

9322 116 242 45A_10 APPS lmichel F50RUN32.EXE

9330 67 440 corp-h APPS applmgr

Once we see all sessions within Oracle, the next step is to run a script to detect all locked sessions. This is because Oracle may not detect a dead session quickly enough to prevent a blockage in data access. The first script below can be run to locate those sessions that are holding locked resources.

Once located, you can run this next script to automatically create the "alter session" syntax to kill the session that your desire to remove the locked sessions from Oracle:

spool run_nuke.sql

select

'alter system kill session '''||

sess.sid||', '||sess.serial#||';'

from

v$locked_object lo,

dba_objects ao,

v$session sess

where

ao.object_id = lo.object_id

and

lo.session_id = sess.sid;


After you have created the run_nuke.sql file, you can quickly select those sessions to kill and run them independently.

Changes to v$sessions

In the past, sessions experiencing waits were generally located by joining the v$session_wait view with the v$sessions view. To simplify the query, all the wait event columns from v$session_wait have been added to v$sessions.

Use the statement below to determine the wait events that involve the most sessions.

SELECT wait_class, count(username)
FROM v$session GROUP BY wait_class;


New columns have been added to v$sessions as follows:

SQL_CHILD_NUMBER, PREV_CHILD_NUMBER, BLOCKING_SESSION_STATUS, BLOCKING_SESSION, SEQ#, EVENT#, EVENT, WAIT_CLASS#, WAIT_CLASS, WAIT_TIME, SECONDS_IN_WAIT, STATE and SERVICE_NAME

Changes to v$session_wait

The new columns include wait_class# and wait_class.

 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.