v$locked_object视图列出当前系统中哪些对象正被锁定
Column | Datatype | Description |
XIDUSN | NUMBER | 回滚段号 |
XIDSLOT | NUMBER | 槽号 |
XIDSQN | NUMBER | 序列号 |
OBJECT_ID | NUMBER | 被锁对象ID |
SESSION_ID | NUMBER | 持有锁的会话ID |
ORACLE_USERNAME | VARCHAR2(30) | 持有锁的Oracle用户名 |
OS_USER_NAME | VARCHAR2(30) | 持有锁的系统用户名 |
PROCESS | VARCHAR2(12) | 操作系统进程号 |
LOCKED_MODE | NUMBER | 锁模式 |
示例:
1 --对表 t1 加锁 2 3 SQL> select * from t1 for update ; 4 5 --查看v$locked_object 6 SQL> SELECT OBJECT_ID,SESSION_ID,LOCKED_MODE FROM V$LOCKED_OBJECT; 7 8 OBJECT_ID SESSION_ID LOCKED_MODE 9 ---------- ---------- -----------10 53252 134 311 12 SQL>13 14 --查看持有锁的会话,及被锁对象名称15 SQL> SELECT T2.USERNAME, T2.SID, T2.SERIAL#, T3.object_name,T2.LOGON_TIME16 2 FROM V$LOCKED_OBJECT T1, V$SESSION T2, DBA_OBJECTS T317 3 WHERE T1.object_id = T3.object_id and T1.session_id = T2.sid18 4 ORDER BY T2.LOGON_TIME;19 20 USERNAME SID SERIAL# OBJECT_NAME LOGON_TIM21 ---------- ---------- ---------- --------------- ---------22 SYS 134 496 T1 12-AUG-13