怎么查看oracle是否有死锁-- 死锁查询语句
SELECTbs.username "Blocking User", bs.username "DB User",
ws.username "Waiting User", bs.SID "SID", ws.SID "WSID",
bs.serial# "Serial#", bs.sql_address "address",
bs.sql_hash_value "Sql hash", bs.program "Blocking App",
ws.program "Waiting App", bs.machine "Blocking Machine",
ws.machine "Waiting Machine", bs.osuser "Blocking OS User",
ws.osuser "Waiting OS User", bs.serial# "Serial#",
ws.serial# "WSerial#",
DECODE (wk.TYPE,
'MR', 'Media Recovery',
'RT', 'Redo Thread',
'UN', 'USER Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL USER LOCK',
'DX', 'Distributed Xaction',
'CF', 'Control FILE',
'IS', 'Instance State',
'FS', 'FILE SET',
'IR', 'Instance Recovery',
'ST', 'Disk SPACE Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalidation',
'LS', 'LOG START OR Switch',
'RW', 'ROW Wait',
'SQ', 'Sequence Number',
'TE', 'Extend TABLE',
'TT', 'Temp TABLE',
wk.TYPE
) lock_type,
DECODE (hk.lmode,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (hk.lmode)
) mode_held,
DECODE (wk.request,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (wk.request)
) mode_requested,
TO_CHAR (hk.id1) lock_id1, TO_CHAR (hk.id2) lock_id2,
DECODE
(hk.BLOCK,
0, 'NOT Blocking',/**//* Not blocking any other processes */
1, 'Blocking',/**//* This lock blocks other processes */
2, 'Global',/**//* This lock is global, so we can't tell */
TO_CHAR (hk.BLOCK)
) blocking_others
FROM v$lock hk, v$session bs, v$lock wk, v$session ws
WHERE hk.BLOCK = 1
AND hk.lmode != 0
AND hk.lmode != 1
AND wk.request != 0
AND wk.TYPE( ) = hk.TYPE
AND wk.id1( ) = hk.id1
AND wk.id2( ) = hk.id2
AND hk.SID = bs.SID( )
AND wk.SID = ws.SID( )
AND (bs.username IS NOT NULL)
AND (bs.username'SYSTEM')
AND (bs.username'SYS')
ORDER BY 1;
查询发生死锁的select语句
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)
)
oracle 如何查看有没有死锁-- 死锁查询语句
SELECTbs.username "Blocking User", bs.username "DB User",
ws.username "Waiting User", bs.SID "SID", ws.SID "WSID",
bs.serial# "Serial#", bs.sql_address "address",
bs.sql_hash_value "Sql hash", bs.program "Blocking App",
ws.program "Waiting App", bs.machine "Blocking Machine",
ws.machine "Waiting Machine", bs.osuser "Blocking OS User",
ws.osuser "Waiting OS User", bs.serial# "Serial#",
ws.serial# "WSerial#",
DECODE (wk.TYPE,
'MR', 'Media Recovery',
'RT', 'Redo Thread',
'UN', 'USER Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL USER LOCK',
'DX', 'Distributed Xaction',
'CF', 'Control FILE',
'IS', 'Instance State',
'FS', 'FILE SET',
'IR', 'Instance Recovery',
'ST', 'Disk SPACE Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalidation',
'LS', 'LOG START OR Switch',
'RW', 'ROW Wait',
'SQ', 'Sequence Number',
【Oracle怎么知道死锁 oracle 查死锁语句】'TE', 'Extend TABLE',
'TT', 'Temp TABLE',
wk.TYPE
) lock_type,
DECODE (hk.lmode,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (hk.lmode)
) mode_held,
DECODE (wk.request,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (wk.request)
) mode_requested,
TO_CHAR (hk.id1) lock_id1, TO_CHAR (hk.id2) lock_id2,
DECODE
(hk.BLOCK,
0, 'NOT Blocking',/**//* Not blocking any other processes */
1, 'Blocking',/**//* This lock blocks other processes */
2, 'Global',/**//* This lock is global, so we can't tell */
TO_CHAR (hk.BLOCK)
) blocking_others
FROM v$lock hk, v$session bs, v$lock wk, v$session ws
WHERE hk.BLOCK = 1
AND hk.lmode != 0
AND hk.lmode != 1
AND wk.request != 0
AND wk.TYPE( ) = hk.TYPE
AND wk.id1( ) = hk.id1
AND wk.id2( ) = hk.id2
AND hk.SID = bs.SID( )
AND wk.SID = ws.SID( )
AND (bs.username IS NOT NULL)
AND (bs.username'SYSTEM')
AND (bs.username'SYS')
ORDER BY 1;
查询发生死锁的select语句
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)
)
oracle 怎么查看数据被锁1.创建测试表,如下图 。
createtabletest_lock(idnumber,valuevarchar2(200));
2.执行append语句;并且不做提交 , insert/* append*/intotest_lockvalues(1,1)如下图 。
3.再次执行清表语句,truncatetabletest_lock;报锁表错误,如下图 。
4.查看锁表语句,发现被锁表
selectb.object_name,t.*
fromv$locked_objectt,user_objectsb
wheret.object_id=b.object_id
注意事项:
简化数据:可以将复杂的查询创建为其他人可以使用的视图 , 而不必了解复杂的业务或逻辑关系 。这简化并掩盖了视图用户数据的复杂性 。
表结构设计的补充:在设计的系统才刚刚开始,大部分的程序直接访问数据表结构,但是随着业务的变化,系统更新,等等,引起了一些表结构不适用,这次修改系统的表结构太大,开发成本较高的影响 。
这个时候可以创建一个视图来补充表结构设计,降低开发成本 。程序可以通过查询视图直接获得它想要的数据 。
添加安全性:视图可以向用户显示表中的指定字段,而不是向用户显示表中的所有字段 。在实际开发中,视图通常作为提供数据的一种方式提供 , 并将只读权限提供给第三方以供查询使用 。
如何查询oracle的死锁?下面查询可以查到死锁,但是注意其实查询到的不是真正的死锁,查询到的只是是死锁发生前的等待条件,真正的死锁在10G中会被系统所阻止掉
select t2.username||''||t2.sid||''||t2.serial#||''||t2.logon_time||''||t3.sql_text
from v$locked_object t1,v$session t2,v$sqltext t3
where t1.session_id=t2.sid
and t2.sql_address=t3.address
order by t2.logon_time ;
此外,从V$LOCK的BLOCK字段可以看到 , BLOCK0表示有等待发生了,注意是行级等待,而在表级没有死锁或等待
select * from v$lock where block0 ;
关于Oracle怎么知道死锁和oracle 查死锁语句的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 怎么调电脑的显卡设置参数,如何调电脑显卡
- 齐天什么电视,齐天什么电视剧
- excel表格如何把字竖着,excel表格如何把字竖着排列
- 服装直播镜头技巧,服装直播摄像头摆放图解
- oracle怎么解除用户 oracle用户被锁住怎么解锁
- oracle临时表redo,oracle临时表空间不足报错
- oracle安装总提示无效字符,oracle ora00911 无效字符
- 直播打仗骗局素材,直播诈骗套路
- C语言函数调用冒泡排序 用c语言冒泡法将数据进行排序