/**locked*query locked object and analyse Reason,kill it**/select ' alter system kill session ' | | SID | | ',' || serial# | | ''';' From (select distinct A.sid, a.serial#, status, Machi NE, lockwait, logon_time from V$session A, V$locked_object b WHERE (a.status = ' ACTIVE ' or a.status = ' INACTIVE ') and A.sid = b.session_id and B.oracle_username = ' xyhistest '--plus user name can filter user resources)/*2, batch execute the first step generated statement alter system kill session ' sid,serial# '; alter system kill Sess Ion ' 6976,33967 '; *//*3, query Oracle user name, machine name, Lock Table object */select l.session_id sid, S.serial#, L.locked_mode, L.ora Cle_username, L.os_user_name, S.machine, S.terminal, O.object_name, s.logon_time from V$loc Ked_object L, all_objects o, v$session s WHERE l.object_id = o.object_id and l.session_id = S.sid ORDER by SID, S.serial #;/*3 or */sele.CT S.sid, S.osuser, p.spid as Ospid, S.machine, S.terminal, S.program from V$session S, v$process p where S.sid = 6--ses sion_id and s.paddr = p.addr;/*4, query is what SQL statement causes the lock table */select B.sql_text from V$session A, v$sql b where a.sid = 6--sessio n_id and a.sql_address = b.address (+),/*5, query is a */select l.session_id sid that causes the lock table to be executed by the SQL statement, s.serial#, L.locked_mod E, L.oracle_username, s.user#, L.os_user_name, S.machine, s.terminal, A.sql_text, A.action from V$sqlarea A, v$session s, v$locked_object l WHERE l.session_id = s.sid and s.prev_sql_addr = a.address ORDER by Sid, S.serial#;
Oracle View lock table condition and handle lock table