select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_mode
from v$locked_object lo, dba_objects ao, v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;
alter system kill session '738,1429';
SELECT 'alter system kill session ''' || SID || ',' || SERIAL# || ''';'
FROM v$session t1,v$locked_object t2
WHERE t1.sid = t2.SESSION_ID;
select s.sid,s.machine,o.object_name,l.oracle_username,l.locked_mode, 'ALTER SYSTEM KILL SESSION '''||s.sid||', '||s.serial#||''';' Command
from v$locked_object l,v$session s,all_objects o where l.session_id=s.sid and l.object_id=o.object_id;
select V$SESSION.sid,v$session.SERIAL#,v$process.spid,
rtrim(object_type) object_type,rtrim(owner) || '.' || object_name object_name,
decode(lmode, 0, 'None',
1, 'Null',
2, 'Row-S',
3, 'Row-X',
4, 'Share',
5, 'S/Row-X',
6, 'Exclusive', 'Unknown') LockMode,
decode(request, 0, 'None',
1, 'Null',
2, 'Row-S',
3, 'Row-X',
4, 'Share',
5, 'S/Row-X',
6, 'Exclusive', 'Unknown') RequestMode
,ctime, block b,
v$session.username,MACHINE,MODULE,ACTION,
decode(A.type,
'MR', 'Media Recovery',
'RT','Redo Thread',
'UN','User Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL User Lock',
'DX', 'Distributed Xaction',
'CF', 'Control File',
'IS', 'Instance State',
'FS', 'File Set',
'IR', 'Instance Recovery',
'ST', 'Disk Space Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalida-tion',
'LS', 'Log Start or Switch',
'RW', 'Row Wait',
'SQ', 'Sequence Number',
'TE', 'Extend Table',
'TT', 'Temp Table',
'Unknown') LockType
from (SELECT * FROM V$LOCK) A, all_objects, V$SESSION, v$process
where A.sid > 6
and object_name<>'OBJ$'
and A.id1 = all_objects.object_id
and A.sid=v$session.sid
and v$process.addr=v$session.paddr;
select obj.OWNER||'.'||obj.OBJECT_NAME as OBJ_NAME, --// 物件名稱(已經被鎖住)
obj.SUBOBJECT_NAME as SUBOBJ_NAME, --// 子物件名稱(已經被鎖住)
obj.OBJECT_ID as OBJ_ID, --// 物件ID
obj.OBJECT_TYPE as OBJ_TYPE, --// 物件型別
lock_obj.SESSION_ID as SESSION_ID, --// 會話SESSION_ID
lock_obj.ORACLE_USERNAME as ORA_USERNAME, --// ORACLE系統使用者名稱稱
lock_obj.OS_USER_NAME as OS_USERNAME, --// 作業系統使用者名稱稱
lock_obj.PROCESS as PROCESS --// 程式編號
from
( select * from all_objects where object_id in (select object_id from v$locked_object)) obj,
v$locked_object lock_obj
where obj.object_id=lock_obj.object_id;
select LOCK_INFO.OWNER||'.'||LOCK_INFO.OBJ_NAME as OBJ_NAME, --// 物件名稱(已經被鎖住)
LOCK_INFO.SUBOBJ_NAME as SUBOBJ_NAME, --// 子物件名稱(已經被鎖住)
SESS_INFO.MACHINE as MACHINE, --// 機器名稱
LOCK_INFO.SESSION_ID as SESSION_ID, --// 會話SESSION_ID
SESS_INFO.SERIAL# as SERIAL#, --// 會話SERIAL#
LOCK_INFO.ORA_USERNAME as ORA_USERNAME, --// ORACLE系統使用者名稱稱
LOCK_INFO.OS_USERNAME as OS_USERNAME, --// 作業系統使用者名稱稱
LOCK_INFO.PROCESS as PROCESS, --// 程式編號
LOCK_INFO.OBJ_ID as OBJ_ID, --// 物件ID
LOCK_INFO.OBJ_TYPE as OBJ_TYPE, --// 物件型別
SESS_INFO.LOGON_TIME as LOGON_TIME, --// 登入時間
SESS_INFO.PROGRAM as PROGRAM, --// 程式名稱
SESS_INFO.STATUS as STATUS, --// 會話狀態
SESS_INFO.LOCKWAIT as LOCKWAIT, --// 等待鎖
SESS_INFO.ACTION as ACTION, --// 動作
SESS_INFO.CLIENT_INFO as CLIENT_INFO --// 客戶資訊
from
(
select obj.OWNER as OWNER,
obj.OBJECT_NAME as OBJ_NAME,
obj.SUBOBJECT_NAME as SUBOBJ_NAME,
obj.OBJECT_ID as OBJ_ID,
obj.OBJECT_TYPE as OBJ_TYPE,
lock_obj.SESSION_ID as SESSION_ID,
lock_obj.ORACLE_USERNAME as ORA_USERNAME,
lock_obj.OS_USER_NAME as OS_USERNAME,
lock_obj.PROCESS as PROCESS
from
( select * from all_objects where object_id in (select object_id from v$locked_object)) obj,
v$locked_object lock_obj
where obj.object_id=lock_obj.object_id
) LOCK_INFO,
(
select SID,
SERIAL#,
LOCKWAIT,
STATUS,
PROGRAM,
ACTION,
CLIENT_INFO,
LOGON_TIME,
MACHINE
from v$session
) SESS_INFO
where LOCK_INFO.SESSION_ID=SESS_INFO.SID ;
ALTER SYSTEM KILL SESSION 'SESSION_ID,SERIAL#';