oracle怎么查死锁 oracle查看死锁语句

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怎么查死锁 oracle查看死锁语句】)
怎么查看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怎么查看表死锁住的原因1.可能在Oracle中可以有计时器,在频繁操作数据库,update,insert,delete语句,在jobs中能查看到(如图)
2.可能在.net程序中使用到timer控件,频繁的操作数据库update,insert,delete语句(如图)
3.可能在.net程序中使用到Thead(线程)频繁的操作数据库update,insert,delete语句(这个条为个人观点,还未得到证实)
【注释】:此处更新数据量都比较大,比如说update的数据库条数可能在1000条以上,
导致其他操作在等待(update跟其他操作都是同一张表)
4.可能使用到事务处理(Tran),没有提交事务(CommintTran)或者没有回滚事务(Rollback)
【注释】:在SqlServer数据库里面有一个隐式事务,关闭时候,每次修改插入都需要手动提交,不然就会导致死锁
oracle怎样查看死锁的表?查看被锁oracle怎么查死锁的表:
select p.spid,c.object_name,b.session_id,b.oracle_username,b.os_user_name from
v$process p,v$session a, v$locked_object b,all_objects c
where p.addr=a.paddr and a.process=b.process and c.object_id=b.object_id
解锁oracle怎么查死锁:
alter system kill session '146';(其中146为锁住oracle怎么查死锁的进程号)
oracle怎么查死锁的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于oracle查看死锁语句、oracle怎么查死锁的信息别忘了在本站进行查找喔 。

    推荐阅读