【发布时间】:2015-02-12 12:27:20
【问题描述】:
我在数据库记录-TX 表的 3 个会话上创建了锁。
接下来我写了一个查询来检查数据库Oracle上的锁,但有些地方不对:
select
round(s1.seconds_in_wait/60,1) as TIME, s1.event,
s1.blocking_session as SID_A, s1.username as USER_A,
s2.sid as SID_B, s2.username as USER_B
from
v$session s1, v$session s2
where
s1.blocking_session is not null
and s1.seconds_in_wait > 1
and s1.sid = s2.sid
order by
s1.seconds_in_wait desc;
结果:
| Time | Evetn |SID_A| USER_A |SID_B| USER_B |
-------------------------------------------------------------
|10.1 | enq: TX row lock.. | 45 | Schema1 | 54 | Schema1 |
|15.5 | enq: TX row lock.. | 45 | Schema2 | 95 | Schema2 |
应该是这样的:
| Time | Evetn |SID_A| USER_A |SID_B| USER_B |
-------------------------------------------------------------
|10.1 | enq: TX row lock.. | 45 | Schema1 | 54 | Schema2 |
|15.5 | enq: TX row lock.. | 45 | Schema1 | 95 | Schema3 |
哪里有问题,请帮忙。
【问题讨论】:
-
Bad habits to kick : using old-style JOINs - 旧式 逗号分隔的表格列表 样式应该不再使用,而是建议使用ANSI-92 SQL 标准引入的正确的 ANSI JOIN 语法(20 多年前)