欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle查看被锁的表和被锁的进程以及杀掉这个进程

程序员文章站 2022-06-11 18:16:28
-- 1. 查看被锁的表 select p.spid, a.serial#, c.object_name, b.session_id, b.oracle_user...

-- 1. 查看被锁的表

select p.spid, a.serial#, 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

-- 2. 查看是哪个进程锁的

select sid, serial#, username, status, osuser from v$session where serial# = '5002'

select sid, serial#, username, status, osuser from v$session where serial# = '3789'

-- 3. 杀掉这个进程

alter system kill session 'sid,serial#';
alter system kill session '269,3789';
alter system kill session '34,4661';
alter system kill session '265,5002';
alter system kill session '289,1688';
alter system kill session '282,5799';