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锁处理、解锁方法,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
Oracle 基本概念 Dadabase,schema,user,table...
dbeaver连接Oracle中文乱码的解决方案--druid
Oracle常用语句(时间格式、去重、去特殊符号、查询表空间等)
Navicate 如何导出数据库中的存储过程、事件、视图等?
每日一记:Oracle升级2020年4月份的数据库补丁Database Patch Set Update : 11.2.0.4.200414 (30670774)
网友评论