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
NUMBER
Undo segment number
XIDSLOT
NUMBER
Slot number
XIDSQN
NUMBER
Sequence number
OBJECT_ID
NUMBER
Object ID being locked
SESSION_ID
NUMBER
Session 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
NUMBER
Lock 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
NUMBER
The 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
NUMBER
Identifier 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_TYPE
data dictionary view, described on "V$LOCK_TYPE".-- 我们主要关注TX 和TM 两种类型的锁
--UL 锁用户自己定义的,一般很少会定义,基本不用关注
ID1
NUMBER
Lock identifier #1 (depends on type)
ID2
NUMBER
Lock 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
NUMBER
Lock 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
NUMBER
Lock 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
NUMBER
Time since current mode was granted
BLOCK
NUMBER
Indicates 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
NUMBER
The 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 ...
随机推荐
- 转载:AOP那点事
原作者:黄勇 博客地址:https://my.oschina.net/huangyong/blog/161338 又是一个周末,刚给宝宝喂完牛奶,终于让她睡着了.所以现在我才能腾出手来,坐在电脑面前给 ...
- 炫酷霸气的HTML5/jQuery应用及源码
也许在5年前,HTML5还是一种很前卫的技术,大家还只是将它当做实验来看待,更别说产品应用了.但是现在HTML5已经非常流行,无论从PC端还是移动端,HTML5都扮演着非常重要的角色.今天我们要分享的 ...
- win用VNC远程Ubuntu教程
转载:https://blog.csdn.net/jiangchao3392/article/details/73251175 1.安装Xrdp Windows远程桌面使用的是RDP协议,所以ubun ...
- Oracle 一个中文汉字 占用几个字节,由Oracle中字符集编码决定
Oracle 一个中文汉字 占用几个字节,要根据Oracle中字符集编码决定 查看oracle server端字符集 select userenv('language') from dual; 如果显 ...
- [Learn AF3]第三章 App Framework 3组件之Panel:afui的核心
Panel,afui的核心组件 组件名称:Panel 使用说明:按照官方的说法,panel组件是af3的“核心(heart of the ui)”,panel用于构造应用中独立的内容展示区域, ...
- 录制iPhone屏幕并转成gif方案
app的开发经常会碰到需要演示一个交互,或者一个bug的情况,通常涉及一连串的操作以及操作的反馈,这是文字,或截图都无法表达的,视频的话还得播放器参与,最好的一个想法应该是录制屏幕然后再转成gif图片 ...
- scanf_s,scanf安全版本
%s,%c必须加sizeof(it)
- jQuery form的load函数与el表达式赋值的冲突问题
问题: 在使用el表达式给表单中的项赋初始值的时候,总是失败,物流公司没有自动选中,物流单号也没有显示值. <form id="form" method="post ...
- 纯CSS实现瀑布流布局
https://www.w3cplus.com/css/pure-css-create-masonry-layout.html
- Android安装器学习笔记(一)
Android安装器学习笔记(一) 一.Android应用的四种安装方式: 1.通过系统应用PackageInstaller.apk进行安装,安装过程中会让用户确认 2.系统程序安装:在开机的时候自动 ...