Lock query:
-----------------
SELECT vs.inst_id,vs.audsid audsid, locks.SID SID, vs.serial# serial#,
vs.username oracle_user, vs.osuser os_user, vs.program program,
vs.module module, vs.action action, vs.process process,
DECODE (locks.lmode,
1, NULL,
2, 'Row Share',
3, 'Row Exclusive',
4, 'Share',
5, 'Share Row Exclusive',
6, 'Exclusive',
'None'
) lock_mode_held,
DECODE (locks.request,
1, NULL,
2, 'Row Share',
3, 'Row Exclusive',
4, 'Share',
5, 'Share Row Exclusive',
6, 'Exclusive',
'None'
) lock_mode_requested,
DECODE (locks.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 Invalidation',
'LS', 'Log Start or Log Switch',
'RW', 'Row Wait',
'SQ', 'Sequence Number',
'TE', 'Extend Table',
'TT', 'Temp Table',
locks.TYPE
) lock_type,
objs.owner object_owner, objs.object_name object_name,
objs.object_type object_type,
ROUND (locks.ctime / 60, 2) lock_time_in_minutes
FROM gv$session vs, v$lock locks, dba_objects objs, dba_tables tbls
WHERE locks.id1 = objs.object_id
AND vs.SID = locks.SID
AND objs.owner = tbls.owner
AND objs.object_name = tbls.table_name
AND objs.owner != 'SYS'
AND locks.TYPE = 'TM'
ORDER BY lock_time_in_minutes;
Kill Session:
-------------------
alter system kill session 'SID,SERIAL#,@INST_ID';
alter system kill session '2328,33131,@1';