1.顯示Linux數(shù)據(jù)庫中鎖信息
select sid,addr kaddr,type,lmode,block from v$lock;
SID KADDR TY LMODE BLOCK-
---------- ---------------- -- ---------- ----------
3 0000000077459298 XR 1 0
3 0000000077459368 RD 1 0
3 0000000077459438 CF 2 0
3 00000000774595D8 RS 2 0
127 00000000774596A8 PW 3 0
189 0000000077459778 RT 6 0
196 0000000077459848 AE 4 0
190 0000000077459918 AE 4 0
66 00000000774599E8 TS 3 0
127 0000000077459AB8 MR 4 0
127 0000000077459B88 MR 4 0
SID KADDR TY LMODE BLOCK
---------- ---------------- -- ---------- ----------
127 0000000077459C58 MR 4 0
127 0000000077459D28 MR 4 0
127 0000000077459DF8 MR 4 0
191 0000000077459EC8 AE 4 0
191 0000000077459FB0 TX 0 0
133 000000007745A080 AE 4 0
196 00007F913A138DE0 TM 3 0
191 00007F913A138DE0 TM 3 0
196 0000000076034228 TX 6 1
2.持有鎖session 196 信息
執(zhí)行語句
SQL> update dept set dname='sale' where deptno='30';
1 row updated.
SQL> SELECT SID FROM V$MYSTAT WHERE ROWNUM =1;
SID
----------
196
SQL> select sid,username from v$session where sid in
2 (select sid from v$lock where block=1);
SID USERNAME
---------- ------------------------------
196 SYS
3.顯示爭用鎖session 191的 SID,username,ID1,執(zhí)行SQL語句
爭用session執(zhí)行語句
SQL> update dept set dname='sale' where deptno='30';
session 191無法獲得RX鎖,等待持有鎖session 196釋放RX
select B.sid,b.username,D.id1,a.sql_text
from v$session b,v$lock D,v$sqltext A
where B.lockwait=d.kaddr
and a.address=b.sql_address
and a.hash_value=b.sql_hash_value;
SID USERNAME ID1 SQL_TEXT
---------- ------------------------------ ---------- ----------------------------------------------------------------
191 SYS 393226 update dept set dname='sale' where deptno='30'
4.顯示鎖會話進(jìn)程信息
SELECT s.oSUSEr "os_user",
s.username "user",
s.sid "sid",
s.serial# "serial#",
s.process "pid",
s.status "status",
l.name "Object_locked",
l.mode_held "lock Held"
FROM v$session s,dba_dml_locks l,v$process p
where l.session_id = s.sid and p.addr=s.paddr;
os_user user sid serial# pid status Object_locked lock Held
------------------------------ ------------------------------ ---------- ---------- ------------------------ -------- ------------------------------ -------------
Oracle SYS 196 25 4549 INACTIVE DEPT Row-X (SX)
Oracle SYS 191 19 4867 ACTIVE DEPT Row-X (SX)
持有TX 196 session status為inactive,想要獲得TX鎖191 session status 為Active
5.kill Session
可以選擇殺掉連個(gè)中的任何一個(gè)session,以保證更新成功。
SQL> alter system kill session 'sid,serial#';
SQL> alter system kill session '196,25';
本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國五強(qiáng)!虛擬主機(jī)域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|