Oracle数据字典之——v$lock 和v$locked_object

184 篇文章 18 订阅
12 篇文章 0 订阅

v$lock视图

v$lock视图列出当前系统持有的或正在申请的所有锁的情况,其主要字段说明如下:

11g如下:

字段名称类型说明
ADDRRAW(8)锁定状态对象的地址
KADDRRAW(8)锁的地址
SIDNUMBER会话(SESSION)标识;
TYPEVARCHAR(2)区分该锁保护对象的类型;
ID1NUMBER锁标识1;
ID2NUMBER锁标识2;
LMODENUMBER锁模式:0(None),1(null),2(row share), 3(row exclusive),4 (share),5(share row exclusive),6(exclusive)
REQUESTNUMBER申请的锁模式:具体值同上面的LMODE
CTIMENUMBER已持有或等待锁的时间;
BLOCKNUMBER是否阻塞其它锁申请;

12c如下:

字段名称类型说明
ADDRRAW(8)锁定状态对象的地址
KADDRRAW(8)锁的地址
SIDNUMBER会话(SESSION)标识
TYPEVARCHAR(2)区分该锁保护对象的类型
ID1NUMBER锁标识1
ID2NUMBER锁标识2
LMODENUMBER锁模式:0(None),1(null),2(row share), 3(row exclusive),4 (share),5(share row exclusive),6(exclusive)
REQUESTNUMBER申请的锁模式:具体值同上面的LMODE
CTIMENUMBER已持有或等待锁的时间
BLOCKNUMBER是否阻塞其它锁申请
CON_IDNUMBER所属容器标识

英文:

字段名称类型说明
ADDRRAW(8)Address of lock state object
KADDRRAW(8)Address of lock
SIDNUMBERIdentifier for session holding or acquiring the lock
TYPEVARCHAR(2)Type of user or system lock
The locks on the user types are obtained by user applications. Any process that is blocking others is likely to be holding one of these locks. The user type locks are:
TM - DML enqueue
TX - Transaction enqueue
UL - User supplied
ID1NUMBERLock identifier #1 (depends on type)
ID2NUMBERLock identifier #2 (depends on type)
LMODENUMBERLock mode in which the session holds the lock:
0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)
REQUESTNUMBERLock mode in which the process requests the lock:
0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)
CTIMENUMBERTime since current mode was granted
BLOCKNUMBERIndicates whether the lock in question is blocking other processes. The possible values are:
0 - The lock is not blocking any other processes
1 - The lock is blocking other processes
2 - The lock is not blocking any blocked processes on the local node, but it may or may not be blocking processes on remote nodes. This value is used only in Oracle Real Application Clusters (Oracle RAC) configurations (not in single instance configurations).
CON_IDNUMBERThe ID of the container to which the data pertains. Possible values include:
0: This value is used for rows containing data that pertain to the entire CDB. This value is also used for rows in non-CDBs.
1: This value is used for rows containing data that pertain to only the root
n: Where n is the applicable container ID for the rows containing data

其中在TYPE字段的取值中,本文只关心TM、TX两种DML锁类型;

关于ID1、ID2,TYPE取值不同其含义也有所不同:

TYPEID1ID2
TM被修改表的标识(object_id)0
TX以十进制数值表示该事务所占用的回滚段号与该事务在该回滚段的事务表(Transaction table)中所占用的槽号(slot number,可理解为记录号)。其组成形式为: 0xRRRRSSSS ( RRRR = RBS number, SSSS = slot )。以十进制数值表示环绕(wrap)次数,即该槽(slot)被重用的次数;

v$locked_object视图

v$locked_object视图列出当前系统中哪些对象正被锁定,其主要字段说明如下:
11g如下:

字段名称类型说明
XIDUSNNUMBER回滚段号
XIDSLOTNUMBER槽号
XIDSQNNUMBER序列号
OBJECT_IDNUMBER被锁对象标识
SESSION_IDNUMBER持有锁的会话(SESSION)标识
ORACLE_USERNAMEVARCHAR2(30)持有该锁的Oracle用户名
OS_USER_NAMEVARCHAR2(30)持有该锁的操作系统用户名
PROCESSVARCHAR2(24)操作系统的进程号
LOCKED_MODENUMBER锁模式

12c如下:

字段名称类型说明
XIDUSNNUMBER回滚段号
XIDSLOTNUMBER槽号
XIDSQNNUMBER序列号
OBJECT_IDNUMBER被锁对象标识
SESSION_IDNUMBER持有锁的会话(SESSION)标识
ORACLE_USERNAMEVARCHAR2(128)持有该锁的Oracle用户名
OS_USER_NAMEVARCHAR2(128)持有该锁的操作系统用户名
PROCESSVARCHAR2(24)操作系统的进程号
LOCKED_MODENUMBER锁模式
CON_IDNUMBER所属容器标识

英文:

ColumnDatatypeDescription
XIDUSNNUMBERUndo segment number
XIDSLOTNUMBERSlot number
XIDSQNNUMBERSequence number
OBJECT_IDNUMBERObject ID being locked
SESSION_IDNUMBERSession ID
ORACLE_USERNAMEVARCHAR2(128)Oracle user name
OS_USER_NAMEVARCHAR2(128)Operating system user name
PROCESSVARCHAR2(24)Operating system process ID
LOCKED_MODENUMBERLock mode. The numeric values for this column map to these text values for the lock modes for table locks:
0 - NONE: lock requested but not yet obtained
1 - NULL
2 - ROWS_S (SS): Row Share Lock
3 - ROW_X (SX): Row Exclusive Table Lock
4 - SHARE (S): Share Table Lock
5 - S/ROW-X (SSX): Share Row Exclusive Table Lock
6 - Exclusive (X): Exclusive Table Lock
See Also: Oracle Database Concepts for more information about lock modes for table locks
CON_IDNUMBERThe ID of the container to which the data pertains. Possible values include:
0: This value is used for rows containing data that pertain to the entire CDB. This value is also used for rows in non-CDBs.
1: This value is used for rows containing data that pertain to only the root
n: Where n is the applicable container ID for the rows containing data

参考链接:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/refrn/V-LOCK.html#GUID-87D76889-832C-4BFC-B8B0-154A22721781

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值