查锁住的表,以及kill进程,Oracle常用语句

时间:2024-04-18 23:06:19

--找出所有被锁的对象,定位出哪个回话占用

select l.session_id,o.owner,o.object_name
from v$locked_object l,dba_objects o
where l.object_id=o.object_id;

--所有导致锁的session

select t2.username, t2.sid, t2.serial#, t2.logon_time, t2.SQL_ID
from v$locked_object t1, v$session t2
where t1.session_id = t2.sid
order by t2.logon_time;

  

--kill 所有占用资源的会话

alter system kill session 'sid,serial#';

--查询锁表的具体语句或者过程

select sql_id, hash_value,a.SQL_TEXT from v$sql a where a.sql_id = 'drw7jjgsy0rw1';

  

--给普通用户授权,比如访问v_$session视图的权限等

grant select on v_$session to hr;