查询死锁的Session SQL 语句

/* Formatted on 2018/3/14 23:34:49 (QP5 v5.256.13226.35538) */

  SELECT dob.object_name table_name

       , lo.locked_mode

       , lo.session_id

       , vss.serial#

       , vps.spid

       , vss.action action

       , vss.osuser osuser

       , vss.process ap_pid

       , vps.spid db_pid

       , 'alter system kill session ' || '''' || lo.session_id || ',' || vss.serial# || ''';' kill_command

    FROM v$locked_object lo

       , dba_objects dob

       , v$session vss

       , v$process vps

   WHERE lo.object_id = dob.object_id

     AND lo.session_id = vss.sid

     AND vss.paddr = vps.addr

/* AND  dob.OBJECT_NAME like 'AP_%' */

/*   AND  vss.client_info like 'OU_ID%'  --OU_ID:就是指所在企业的OU的ID*/

ORDER BY 2, 3, dob.object_name;

posted @ 2018-03-14 23:36  全威儒  阅读(499)  评论(0编辑  收藏  举报