oracle锁表问题

查询表的状况的对象:V$LOCK, V$LOCKED_OBJECT, V$SESSION, V$SQLAREA, V$PROCESS

select * from v$locked_object
select * from dba_objects

方法:

首先查看那些表被锁住了

select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id;


select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time;

杀进程中的会话

alter system kill session 'sid,serial#';
例如:
alter system kill session '29,5497';

查询锁表的方法:

SELECT S.SID SESSION_ID, S.USERNAME, s.SERIAL#,
DECODE(LMODE, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive',
 TO_CHAR(LMODE)) MODE_HELD, DECODE(REQUEST, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive',
 TO_CHAR(REQUEST)) MODE_REQUESTED, O.OWNER||'.'||O.OBJECT_NAME||' ('||O.OBJECT_TYPE||')',
 S.TYPE LOCK_TYPE, L.ID1 LOCK_ID1, L.ID2 LOCK_ID2
 FROM V$LOCK L, SYS.DBA_OBJECTS O, V$SESSION S
 WHERE L.SID = S.SID AND L.ID1 = O.OBJECT_ID ;

解锁方法:

ALTER SYSTEM KILL SESSION 'SID,SERIR#'

你可能感兴趣的:(oracle)