您好,登錄后才能下訂單哦!
本篇文章為大家展示了Oracle中有哪些鎖處理方式,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
1、查詢鎖情況
select sid,serial#,event,BLOCKING_SESSION from v$session where event like '%TX%';
2、根據(jù)SID查詢具體信息(可忽略)
select sid,serial#,username,machine,blocking_session from v$session where sid=<SID>;
3、殺掉會(huì)話
#根據(jù)1和2中查到的SID和SERIAL# 定位會(huì)話,并殺掉
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;
上述內(nèi)容就是Oracle中有哪些鎖處理方式,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。