oracle 查看锁表sql语句(导致锁表的sql)、解锁语句

–查看锁表进程SQL语句1:

–被锁对象表、数据库对象表、数据session表关联来获取被锁对象对应的是那个session;
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v l o c k e d o b j e c t l o , d b a o b j e c t s a o , v locked_object lo, dba_objects ao, v lockedobjectlo,dbaobjectsao,vsession sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

–查看锁表进程SQL语句2:
select * from v s e s s i o n t 1 , v session t1, v sessiont1,vlocked_object t2 where t1.sid = t2.SESSION_ID;

–查看导致锁表的sql语句是那一条

select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
s.user#,
l.os_user_name,
s.machine,
s.terminal,
a.sql_text,
a.action
from v s q l a r e a a , v sqlarea a, v sqlareaa,vsession s, v$locked_object l
where l.session_id = s.sid
and s.prev_sql_addr = a.address
order by sid, s.serial#;

–杀掉锁表进程:

–通过上面的查询获取SID和serial#,替换下面的x,y,就可以解除被锁的状态
alter system kill session ‘x,y’;

你可能感兴趣的:(oracle)