Oracle中V$SESSION等各表的字段解释,Oracle官方解释
一、常用的视图
1.会话相关视图
| View | Description |
|---|---|
|
|
Contains information about the currently active processes |
|
|
Lists session information for each current session |
|
|
Contains I/O statistics for each user session |
|
|
Displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution. More operations are added for every Oracle Database release. |
|
|
Displays the current or last wait for each session |
|
|
Lists the last ten wait events for each active session |
|
|
Displays information about blocked sessions |
|
|
Contains session statistics |
|
|
Provides information about current and maximum global resource utilization for some system resources |
|
|
Contains statistics about shared SQL areas. Contains one row for each SQL string. Provides statistics about SQL statements that are in memory, parsed, and ready for execution |
2.锁相关的视图:
View Description Lists the locks currently held by Oracle Database and outstanding requests for a lock or latch
Displays a session if it is holding a lock on an object for which another session is waiting
Displays a session if it is waiting for a locked object
Lists all DDL locks held in the database and all outstanding requests for a DDL lock
Lists all DML locks held in the database and all outstanding requests for a DML lock
Lists all locks or latches held in the database and all outstanding requests for a lock or latch
Displays a row for each lock or latch that is being held, and one row for each outstanding request for a lock or latch
Lists all locks acquired by every transaction on the system
Lists the resources or events for which active sessions are waiting
Contains session statistics
Provides information about current and maximum global resource utilization for some system resources
Contains statistics about shared SQL area and contains one row for each SQL string. Also provides statistics about SQL statements that are in memory, parsed, and ready for execution
Contains statistics for nonparent latches and summary statistics for parent latches
二、V$SESSION
三、V$SESSION_WAIT
这里面有个event字段,event字段的枚举值可以存在下面的表中,可以这样查询:
SELECT name, wait_class FROM V$EVENT_NAME ORDER BY name

1. 查询会话正在等待行锁的会话:
select event,sid,p1,p2,p3 from v$session_wait where event='enq: TX - row lock contention';

三、V$LOCKED_OBJECT
1.简介及表字段
该表列出每个事务获取到的所有锁。它可以展示出哪个会话正在持有锁,在什么对象上持有锁,以及锁的模式。
Column Datatype Description
XIDUSN
NUMBERUndo segment number
XIDSLOT
NUMBERSlot number
XIDSQN
NUMBERSequence number
OBJECT_ID
NUMBERObject ID being locked
SESSION_ID
NUMBERSession ID
ORACLE_USERNAME
VARCHAR2(128)Oracle user name
OS_USER_NAME
VARCHAR2(128)Operating system user name
PROCESS
VARCHAR2(24)Operating system process ID
LOCKED_MODE
NUMBERLock 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 LockSee Also: Oracle Database Concepts for more information about lock modes for table locks
CON_ID
NUMBERThe 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 rootn: Where n is the applicable container ID for the rows containing data
2.查询持有锁的会话
SELECT USERNAME, LOCKWAIT, STATUS, MACHINE, PROGRAM FROM V$SESSION WHERE SID IN (SELECT SESSION_ID FROM V$LOCKED_OBJECT);

3.查询持有锁的会话正在执行的sql
SELECT
SQL_TEXT
FROM
V$SQL
WHERE
HASH_VALUE IN (
SELECT
SQL_HASH_VALUE
FROM
V$SESSION
WHERE
SID IN (
SELECT
SESSION_ID
FROM
V$LOCKED_OBJECT
)
);

4.根据对象名查询持有该锁对象的会话
SELECT o.object_name,s.sid, s.serial#
FROM v$locked_object l, dba_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid AND o.object_name='SEATINFORMATION';
SEATINFORMATION为本地表的名字。

5.根据对象名查询持有该锁对象的会话及sql
SELECT o.object_name,s.sid, s.serial#,s.SQL_HASH_VALUE,v.*
FROM v$locked_object l, dba_objects o, v$session s, V$SQL v
WHERE l.object_id = o.object_id
AND l.session_id = s.sid and s.SQL_HASH_VALUE = v.HASH_VALUE AND o.object_name='INCIDENTINFORMATION';
四、V$LOCK
1.简介
该视图列出当前被oracle持有的锁。
Column Datatype Description
ADDR
RAW(4 | 8)Address of lock state object
KADDR
RAW(4 | 8)Address of lock
SID
NUMBERIdentifier for session holding or acquiring the lock
TYPE
VARCHAR2(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 suppliedThe system type locks are listed in Table 8-1. Be aware that not all types of locks are documented. To find a complete list of locks for the current release, query the
V$LOCK_TYPEdata dictionary view, described on "V$LOCK_TYPE".-- 我们主要关注TX 和TM 两种类型的锁
--UL 锁用户自己定义的,一般很少会定义,基本不用关注
ID1
NUMBERLock identifier #1 (depends on type)
ID2
NUMBERLock identifier #2 (depends on type)
--- 当lock type 为TM 时,id1 为DML-locked object 的object_id
--- 当lock type 为TX 时,id1 为usn+slot ,而id2 为seq 。
-- 当lock type 为其它时,不用关注
LMODE
NUMBERLock 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)--大于0时表示 当前会话以某种模式 占有 该锁,等于0时表示当前会话正在等待该锁资源,即表示该会话被阻塞。
--大于0时表示 当前会话以某种模式 占有 该锁,等于0时表示当前会话正在等待该锁资源,即表示该会话被阻塞。
往往在发生TX 锁时,伴随着TM 锁,比如一个sid=9 会话拥有一个TM 锁,一般会拥有一个或几个TX锁,但他们的id1 和id2 是不同的,请注意
REQUEST
NUMBERLock 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)-- 大于0时,表示当前会话被阻塞,其它会话占有该锁的模式
CTIME
NUMBERTime since current mode was granted
BLOCK
NUMBERIndicates 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_ID
NUMBERThe 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 rootn: Where n is the applicable container ID for the rows containing data
2.一个本地的死锁案例:
从oracle服务器的trace日志中看到:

会话432和会话188互相等待。
以下是相关信息:
2.1 会话432的持有的锁,被锁的对象,正在执行的sql:
SELECT * FROM V$LOCK l where l.sid = ;

https://logicalread.com/diagnosing-oracle-wait-for-tx-enqueue-mode-6-mc01/#.XBUGJM7_zIU
Oracle中V$SESSION等各表的字段解释,Oracle官方解释的更多相关文章
- Oracle 中 根据值 查询 所在 表和字段
-------------------- -- 这里是查询 数字型字段值 /*declare CURSOR cur_query IS select table_name, column_name, d ...
- Oracle中Kill session的研究(转 出自eagle)
itpub link: http://www.itpub.net/235873.html 我们知道,在Oracle数据库中,可以通过kill session的方式来终止一个进程,其基本语法结构为: a ...
- ORACLE 中KILL session
我们知道,在Oracle数据库中,可以通过kill session的方式来终止一个进程,其基本语法结构为: alter system kill session 'sid,serial#' ; 被kil ...
- Oracle中使用游标转换数据表中指定字段内容格式(拼音转数字)
应用场景:将数据表TB_USER中字段NNDP的内容中为[sannanyinv]转换为[3男1女] 主要脚本:一个游标脚本+分割字符串函数+拼音转数字脚本 操作步骤如下: 1.创建类型 create ...
- 恢复oracle中误删除drop掉的表 闪回的方法
恢复oracle中误删除drop掉的表 查看回收站中表 --需要在其所在用户下查询 回收站对象 select object_name,original_name,partition_name,ty ...
- ORACLE中如何找出大表分布在哪些数据文件中?
ORACLE中如何找出大表分布在哪些数据文件中? 在ORACLE数据中,我们能否找出一个大表的段对象分布在哪些数据文件中呢? 答案是可以,我们可以用下面脚本来找出对应表的区.段分别位于哪些数据文件 ...
- oracle中的rowid--伪列-删除表中的重复内容-实用
1.rowid是一个伪列,是用来确保表中行的唯一性,它并不能指示出行的物理位置,但可以用来定位行. 2.rowid是存储在索引中的一组既定的值(当行确定后).我们可以像表中普通的列一样将它选出来. 3 ...
- ASP.NET MVC中使用Session来保持表单的状态
本篇实践在ASP.NET MVC 4下使用Session来保持表单的状态. 本篇的源码在这里: https://github.com/darrenji/KeepFormStateUsingSessio ...
- Oracle中创建千万级大表归纳
从一月至今,我总共归纳了三种创建千万级大表的方案,它们是: 下面是这三种方案的对比表格: # 名称 地址 主要机制 速度 1 在Oracle中十分钟内创建一张千万级别的表 https://www.cn ...
随机推荐
- add a private constructor to hide the implicit public one(Utility classes should not have public constructors)
sonarlint提示add a private constructor to hide the implicit public one Utility classes should not have ...
- Linux学习笔记(二):实战-根据微服务端口号关闭进程
前言 现在项目组基本都用Springboot,每个服务占用一个端口号,有时需要选择性的关闭,但在任务管理器上他们的名称都是java.exe,无法区分,这才学以致用. killPort.sh 作用:根据 ...
- Runtime、System、Object
Runtime---->Runtime.getRuntime().gc(); System---->System.gc(); Object---->finalize();
- Linux top和负载的解释(转载)
转载自://www.blogjava.net/freeman1984/archive/2011/12/08/365853.html op命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程 ...
- 【Jupyter notebook】access remotly
http://jupyter-notebook.readthedocs.io/en/latest/public_server.html
- json字符串使用注意问题
json本身是字符串,即 json字符串 js使用 要把 json字符串 转为 javascript对象 json字符串转为js对象的方法:jquery的parseJSON var str='[{& ...
- springboot使用@ControllerAdvice(二)之深入理解
前言: 接口类项目开发时,为了便于后期查找问题,一般会拦截器或过滤器中记录每个接口请求的参数与响应值记录, 请求参数很容易从request中获取,但controller的返回值无法从response中 ...
- application/x-www-form-urlencoded 的contentType,POST数据内容过大,导致tomcat的request取不到参数
如题, 可通过设置tomcat的connector的参数 server.xml中的connector中加上属性 maxPostSize="20971520" maxPostSize ...
- 给一个由n-1个整数组成的未排序的序列,其元素都是1~n中的不同的整数。如何在线性时间复杂度内寻找序列中缺失的整数
思路分析:尼玛这不就是等差数列么.首先将该n-1个整数相加,得到sum,然后用(1+n)n/2减去sum,得到的差即为缺失的整数.因为1~n一共n个数,n个数的和为(1+n)n/2,而未排序数列的和为 ...
- WPF送走控件的focus方法
我们可以调用Focus()方法,让WPF控件获得焦点, 那我现在不想要焦点了, 如何把这个包袱抛出去? 可以, 恩, 没有Unfocus(), 但下面的方法也许可行(把焦点抛给另一个不知道的控件): ...