一招解决Oracle锁表(有图详解)

–找出SID,SERIAL#

with s1 as
 (select b.object_name, a.session_id as sid, b.owner, a.locked_mode
    from v$locked_object a, dba_objects b
   where b.object_id = a.object_id),
s2 as
 (SELECT T2.USERNAME, T2.SID, T2.SERIAL# as SERIAL, T2.LOGON_TIME
    FROM V$LOCKED_OBJECT T1, V$SESSION T2
   WHERE T1.SESSION_ID = T2.SID
   ORDER BY T2.LOGON_TIME)

select s1.*, s2.SERIAL from s1 inner join s2 on s1.sid = s2.sid

一招解决Oracle锁表(有图详解)_第1张图片

将上文中查询出的SID,SERIAL放入下面的SQL

–杀死会话

alter system kill session 'SID,SERIAL'

例如:

alter system kill session '99,7359'

你可能感兴趣的:(oracle,数据库)