Locked objects by sessions
                                                 Last update (2008-02-21 11:02:17)
                                                                                                                   Date added (2008-02-13 19:00:33)

Summary
You can find the user type locks on a table using this scripts
SELECT /*+ RULE */  
DECODE(TRUNC(SYSDATE - LOGON_TIME), 0, NULL, TRUNC(SYSDATE - LOGON_TIME) || ' Days' || ' + ') || 
TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE-LOGON_TIME,1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
       lk.SID, se.serial#, pr.spid pid, se.status, se.username, se.osuser, se.machine,
	   DECODE (lk.TYPE,'TX', 'TRANSACTION', 'TM', 'DML', 'UL', 'PL/SQL User Lock', lk.TYPE) TYPE, 
	   DECODE(lk.TYPE, 'TX','TRANSACTION ROW-LEVEL' , 'TS','TEMPORARY SEGMENT ' , 'TD','TABLE LOCK' , 'TM','ROW LOCK' , lk.TYPE ) lock_TYPE,
	   DECODE (lk.lmode, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive', TO_CHAR (lk.lmode)) held,
	   DECODE(ob.owner || '.' || ob.object_name, '.', NULL, ob.owner || '.' || ob.object_name) OBJECT,
       DECODE (lk.request, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive', TO_CHAR (lk.request)) requested,
       DECODE(lk.BLOCK, 0, 'NO', 'YES' ) BLOCKER, 
	   'alter system kill session ' || '''' || se.SID || ', ' || se.serial# || '''' || ' immediate;' kill_sql 
  FROM v$lock lk, dba_objects ob, v$session se, v$process pr
 WHERE lk.SID = se.SID 
 AND lk.id1 = ob.object_id (+) 
 AND se.paddr = pr.addr 
 AND lk.TYPE IN ('TM', 'UL', 'TX')  --User type locks
--AND se.osuser = '' 
--and se.username = 'ATHINA'
--AND se.status = 'INACTIVE'
-- AND lk.lmode = 2
AND ob.object_name LIKE 'PA_PROJECT_ASSETS_ALL%'
AND ob.object_type = 'TABLE' 
--AND owner = 'AR'
ORDER BY LOGON DESC;
Reviews
Categories
Oracle DBA-> (147)
  Alertlog (3)
  Archivelog (5)
  Auditing (1)
  Backup - Recovery (19)
  Database files (6)
  Database options (2)
  DB links (2)
  Dependencies (1)
  Dictionary (2)
  Exp-Imp Datapump (6)
  Jobs (2)
  Mview (2)
  Networking (3)
  Objects (7)
  Parameters (2)
  Redologs (6)
  Roles - Grants (2)
  Rollback - Undo (8)
  Segments (3)
  Sequences (2)
  Sessions (14)
  SGA (14)
  Tables (10)
  Tablespaces (10)
  Temp (4)
  Toad (5)
  Transactions (1)
  Upgrade (2)
  Users (3)
Oracle APPS DBA-> (66)
Exadata (1)
Performance Tuning-> (59)
Oracle Real Cases (24)
Oracle Errors (23)
Oracle SQL tricks (32)
Oracle RAC (3)
Oracle Security (8)
Filters
Search