Oracle锁处理、解锁方法
网络编程 2021-07-05 16:09www.168986.cn编程入门
本文通过实例代码较详细的给大家介绍了Oracle锁处理、解锁方法,需要的朋友可以参考下
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=<SID>;
3、杀掉会话
#根据1和2中查到的SID和SERIAL# 定位会话,并杀掉
ALTER SYSTEM DISCONNECT SESSION '<SID>,<SERIAL>' IMMEDIATE;
或
ALTER SYSTEM KILL SESSION '<SID>,<SERIAL>';
附件
#查询阻塞脚本
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;
以上所述是长沙网络推广给大家介绍的Oracle锁处理、解锁方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,长沙网络推广会及时回复大家的。在此也非常感谢大家对狼蚁SEO网站的支持!
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程