Display Locks and Gives the SID and Serial Number of the session to kill

This script displays locks and gives the SID and Serial Number of the session to kill.

 

REM ------------------------------------------------------------------------
REM PURPOSE:
REM    The report generated by this script gives information on sessions
REM    which are holding locks and gives the information needed to kill
REM    using the ALTER SYSTEM KILL SESSION command.
REM ------------------------------------------------------------------------
REM Main text of script follows:
 
set linesize 132 pagesize 66
break on Kill on username on terminal
column Kill heading 'Kill String' format a13
column res heading 'Resource Type' format 999
column id1 format 9999990
column id2 format 9999990
column lmode heading 'Lock Held' format a20
column request heading 'Lock Requested' format a20
column serial# format 99999
column username  format a10  heading "Username"
column terminal heading Term format a6
column tab format a35 heading "Table Name"
column owner format a9
column Address format a18
select        nvl(S.USERNAME,'Internal') username,
        nvl(S.TERMINAL,'None') terminal,
        L.SID||','||S.SERIAL# Kill,
        U1.NAME||'.'||substr(T1.NAME,1,20) tab,
        decode(L.LMODE,1,'No Lock',
                2,'Row Share',
                3,'Row Exclusive',
                4,'Share',
                5,'Share Row Exclusive',
                6,'Exclusive',null) lmode,
        decode(L.REQUEST,1,'No Lock',
                2,'Row Share',
                3,'Row Exclusive',
                4,'Share',
                5,'Share Row Exclusive',
                6,'Exclusive',null) request
from        V$LOCK L, 
        V$SESSION S,
        SYS.USER$ U1,
        SYS.OBJ$ T1
where        L.SID = S.SID 
and        T1.OBJ# = decode(L.ID2,0,L.ID1,L.ID2) 
and        U1.USER# = T1.OWNER#
and        S.TYPE != 'BACKGROUND'
order by 1,2,5
/

 

For example:

Username   Term   Kill String   Table Name                                        Lock Held            Lock Requested
----------          ------     -------------  -----------------------------------                --------------------   --------------------
HONCHO     pts/1    159,7         SYS.I_LOBCOMPPART_LOBJPA    Exclusive
                                                        HONCHO.TEST3                               Row Exclusive
HONCHO     pts/2    152,27       HONCHO.TEST3                               Row Exclusive
                                                       SYS.I_LOBCOMPPART_LOBJPA                                   Exclusive

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值