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 ...
随机推荐
- php base64_encode,serialize对于存入数据表中字段的数据处理方案
A better way to save to Database $toDatabse = base64_encode(serialize($data)); // Save to database $ ...
- Java多线程——Lock&Condition
Lock比传统线程模型中的synchronized方式更加面向对象,与生活中的锁类似,锁本身也应该是一个对象.两个线程执行的代码片段要实现同步互斥的效果,它们必须用同一个Lock对象. package ...
- Some Java exceptions, messages and errors.
http://www.antapex.org/messages_java.txt http://www.jvmmonitor.org/index.html
- shell特殊符号cut命令 sort_wc_uniq命令 tee_tr_split命令 shell特殊符号
shell特殊符号cut命令 特殊符号 * 通配符,任意个任意字符 ? 任意一个字符 # 注释字符 \ 脱义字符 c=\$a\$b echo $c | 管道符 cat 1.txt |less ...
- 【WP8】LoopingSelector
WP8的WindowsPhoneToolkit工具包中有一个 LoopingSelector 可以想选择日期或时间一样进行选择 1.首先当然是引用WindowsPhoneToolkit 在Nuget控 ...
- LoadRunner javavuser错误排查
Loadrunner 9.5/11 使用java 开发vsuer script需要的环境配置 本文从两个方面来讲:windows 32位操作系统:windows 64 操作系统开始之前,先说下java ...
- js中如何以最简单的方式将数组元素添加到对象中
//如题,通常做法就是循环数组,最后在添加length属性,如: var obj = {}; var pushArr = [11,22,33,44,55,66]; for(var i=0;i<p ...
- js实现图片粘贴上传到服务器并展示
最近看了一些有关于js实现图片粘贴上传的demo,实现如下: (这里只能检测到截图粘贴和图片右键复制之后粘贴) demo1: document.addEventListener('paste', fu ...
- PGsql 基本用户权限操作
Ⅰ. 安装与初始账户密码修改 1. 安装 sudo apt-get install postgresql-9.4 2. 管理员身份打开pg sudo -u postgres psql sudo -u ...
- android手机内的通讯录数据库
今天看了一下 android手机内的通讯录数据库,简单的汇总了一下. 数据库见附件中的contacts2.db , 里面一共有40个表,34个视图,很庞大,挑几个重点的看一下. 1.表Raw_cont ...