一聚教程网:一个值得你收藏的教程网站

时时彩开奖官网:Oracle锁处理、解锁方法

时间:2018-07-02 19:50:12 编辑:猪哥 来源:转载

1、查询锁情况

select sid,serial#,event,BLOCKING_SESSION from v$session where event like '%TX%';

2、根据SID查询具体信息(可忽略)

select sid,serial#,username,machine,blocking_session from v$session where sid=;

3、杀掉会话

#根据1和2中查到的SID和SERIAL# 定位会话,并杀掉

ALTER SYSTEM DISCONNECT SESSION ',' IMMEDIATE;

ALTER SYSTEM KILL SESSION ',';

 附件:

#查询阻塞脚本

col waiting_session for a20
col lock_type for a15
col mode_requested for a10
col mode_held for a10
col lock_id1 for a10
col lock_id2 for a10
set linesize 120
set pagesize 999
with dba_locks_cust as 
(SELECT  inst_id||'_'||sid session_id,
      DECODE (TYPE,
          'MR', 'Media Recovery',
          'RT', 'Redo Thread',
          'UN', 'User Name',
          'TX', 'Transaction',
          'TM', 'DML',
          'UL', 'PL/SQL User Lock',
          'DX', 'Distributed Xaction',
          'CF', 'Control File',
          'IS', 'Instance State',
          'FS', 'File Set',
          'IR', 'Instance Recovery',
          'ST', 'Disk Space Transaction',
          'TS', 'Temp Segment',
          'IV', 'Library Cache Invalidation',
          'LS', 'Log Start or Switch',
          'RW', 'Row Wait',
          'SQ', 'Sequence Number',
          'TE', 'Extend Table',
          'TT', 'Temp Table',
          TYPE)
        lock_type,
      DECODE (lmode,
          0, 'None',            /* Mon Lock equivalent */
          1, 'Null',                     /* N */
          2, 'Row-S (SS)',                  /* L */
          3, 'Row-X (SX)',                  /* R */
          4, 'Share',                    /* S */
          5, 'S/Row-X (SSX)',                /* C */
          6, 'Exclusive',                  /* X */
          TO_CHAR (lmode))
        mode_held,
      DECODE (request,
          0, 'None',            /* Mon Lock equivalent */
          1, 'Null',                     /* N */
          2, 'Row-S (SS)',                  /* L */
          3, 'Row-X (SX)',                  /* R */
          4, 'Share',                    /* S */
          5, 'S/Row-X (SSX)',                /* C */
          6, 'Exclusive',                  /* X */
          TO_CHAR (request))
        mode_requested,
      TO_CHAR (id1) lock_id1,
      TO_CHAR (id2) lock_id2,
      ctime last_convert,
      DECODE (block,
          0, 'Not Blocking', /* Not blocking any other processes */
          1, 'Blocking',   /* This lock blocks other processes */
          2, 'Global',  /* This lock is global, so we can't tell */
          TO_CHAR (block))
        blocking_others
   FROM gv$lock
),
lock_temp as
(select * from dba_locks_cust),
lock_holder as 
(
 select w.session_id waiting_session,
    h.session_id holding_session,
    w.lock_type,
    h.mode_held,
    w.mode_requested,
    w.lock_id1,
    w.lock_id2
 from lock_temp w, lock_temp h
 where h.blocking_others in ('Blocking','Global')
 and h.mode_held   != 'None'
 and h.mode_held   != 'Null'
 and w.mode_requested != 'None'
 and w.lock_type    = h.lock_type
 and w.lock_id1    = h.lock_id1
 and w.lock_id2    = h.lock_id2
),
lock_holders as
(select waiting_session,holding_session,lock_type,mode_held,
mode_requested,lock_id1,lock_id2
 from lock_holder
 union all
 select holding_session, null, 'None', null, null, null, null 
  from lock_holder
 minus
 select waiting_session, null, 'None', null, null, null, null
  from lock_holder 
 )
select lpad(' ',3*(level-1)) || waiting_session waiting_session,
    lock_type,
    mode_requested,
    mode_held,
    lock_id1,
    lock_id2
 from lock_holders
connect by prior waiting_session = holding_session
 start with holding_session is null;

文章评论

热门栏目

  • 甘肃宣讲十九大:丝路春风三千里,陇原儿女添豪情 2018-12-15
  • 驻工商总局纪检组问责9名司局级干部 持续发力 2018-12-14
  • 韩国一姐探望男排猛将被喊在一起 金软景合影中国男朋友 2018-12-13
  • 江西省“放管服”改革再出实招 2018-12-12
  • 尊重和保障宗教信仰自由的中国实践 2018-12-12
  • 首都电力共产党员先锋 2018-12-11
  • 美联储加息几成定局 专家:中国央行大概率跟随加息 2018-12-10
  • 习近平与人民日报的10个故事 2018-12-10
  • 【理上网来·辉煌十九大】十九大报告谱写中国大国外交新篇章 2018-12-09
  • 世界杯期间 拉萨交警严查酒驾醉驾毒驾 2018-12-08
  • 第十六届中国经济论坛 2018-12-07
  • 共产主义既按需分配又按劳分配(原创) 2018-12-06
  • 财经 俄罗斯世界杯的经济账 2018-12-06
  • 【图解】汶川地震10年:各地援建知多少(上) 2018-12-05
  • 昌都市图书馆首个全民阅读推广项目结题 2018-12-04
  • 471| 622| 415| 661| 683| 954| 143| 60| 385| 766|