View: SELECT username, v$lock.sid, TRUNC (Id1/power (2, +)) RBS, Bitand (id1, To_number (' ffff ', ' xxxx ')) + 0 SLO T, id2 seq, lmode, request from V$lock, v$session where v$lock. TYPE = ' TX ' and v$lock.sid = V$session.sid and v$session.username = USER; USERNAME SID RBS SLOT SEQ lmode REQUEST --------------------------- ---------- ---------- ---------- ---------- ---------- ---------- Eoda 341 7 17 158 6 0 Sql> select xidusn,xidslot,xidsqn from V$transaction; Xidusn Xidslot xidsqn ---------- ---------- ---------- 7 17 158 There are a few interesting things here. The Lmode of the V$lock table is 6,request 0. View Oracle Database Reference get Lmode=6 is an exclusive lock. Requesting request=0 means that you have not made a request, that is to say you have the lock. This v$lock table has only one row. Oracle does not store a list of row-level locks anywhere. To see if a row is locked, you must find the row directly. The RBS, slot, and SEQ values match v$transaction, which is my transaction ID |
Back to the original session
SELECT username, V$lock.sid, TRUNC (Id1/power (2,)) RBS, Bitand (ID1, To_number (' ffff ', ' xxxx ')) + 0 slots, Id2 seq, Lmode, Request From V$lock, v$session WHERE V$lock. TYPE = ' TX ' and V$lock.sid = V$session.sid One and v$session.username = USER; USERNAME SID RBS SLOT SEQ lmode REQUEST ------------------- ---------- ---------- ---------- ---------- ---------- ---------- Eoda 311 10 3 7727 6 0 Eoda 311 7 17 158 0 6 Eoda 341 7 17 158 6 0 Sql> select xidusn,xidslot,xidsqn from V$transaction; xidusn xidslot xidsqn ------------------ ------------ 10 3 7727 7 17 158 Can see that a new transaction has started, the transaction ID is (10,3,7727), and this time, this session (sid=311) has two lines in V$lock. One line represents the lock (lmode=6) he owns. There is another row that shows a request with a value of 6. This is a request for a team exclusive lock. Interestingly, the RBS/SLOT/SEQ value of this request line is exactly the transaction ID of the lock holder. The sid=341 transaction is blocking the sid=311 transaction. As you can see from V$lock's self-connected query: Select username from v$session WHERE sid = A.sid) Blocker, a.sid, ' is Blocking ', (SELECT username from V$session WHERE sid = B.sid) & nbsp; Blockee, b.sid From V$lock A, V$lock b 13 WHERE a.block = 1 and b.request > 0 and a.id1 = b.id1 and A.id2 = b.id2; Blocker sid ' Isblocking ' blockee sid ------------------------------ ---------- ------------- ------------------------------ ---------- Eoda 341 is blocking Eoda 311 Now, commit the original transaction (sid=341), query again, and you can see that the request line is gone. Sql> commit; Commit complete. SELECT username, v$lock.sid, TRUNC (Id1/power (2, +)) RBS, Bitand (id1, To_number (' ffff ', ' xxxx ')) + 0 SLO T, id2 seq, lmode, request from V$lock, v$session where v$lock. TYPE = ' TX ' and v$lock.sid = V$session.sid 11 and v$session.username = USER; USERNAME SID RBS SLOT SEQ lmode REQUEST ------------------------------ ---------- ---------- ---------- ---------- ---------- ---------- Eoda 311 10 3 7727 6 0 Another session can also see the update complete, ending the blocked state. sql> Update emp Set Ename=upper (ename); Rows updated. Sql> Update dept Set deptno=deptno-10; 4 rows updated. |