--(查询数据库表的锁的情况)
select * from v$lock;
--(查询对象信息)
select * from sysobjects;
--(查询会话信息)
select * from v$sessions;
--关联查询
select
a.* ,
b.NAME,
c.SESS_ID
from
v$lock a
left join sysobjects b
on
b.ID=a.TABLE_ID
left join v$sessions c
on
a.TRX_ID=c.TRX_ID
--查询当前阻塞的sql语句及状态
select
"V$SESSIONS".SESS_ID ,
"V$SESSIONS".SQL_TEXT ,
"V$SESSIONS".STATE ,
"V$SESSIONS".CURR_SCH ,
"V$SESSIONS".USER_NAME,
"V$SESSIONS".TRX_ID ,
"V$SESSIONS".CREATE_TIME
from
v$sessions
where
trx_id in
(
select
trx_id
from
v$lock
where
table_id in
(
select
tab.id
from
sysobjects sch,
sysobjects tab
where
tab.schid=sch.id
and sch.name
||'.'
||tab.name='SYSDBA.TEST'
)
)
and SQL_TEXT like '%insert%'
or SQL_TEXT like '%update%'
or SQL_TEXT like '%delete%';
--杀掉阻塞(需要切换到管理员用户)
sp_close_session(sess_id);
版权声明:本文为iloki原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。