Posts Tagged ‘Database DBA’

LOCK TABLES and UNLOCK TABLES Syntax For ORACLE

December 11th, 2013, posted in Oracle Queries
Share
Identify locked objects :

select object_name, v.session_id SID, v.oracle_username,type,lmode,request
       from v$locked_object v, v$lock l, dba_objects o
       where l.sid=v.session_id
       and v.object_id=o.object_id
       and l.block > 0;

Identify who locks whom :

select
      (select osuser from v$session where sid=a.sid) blocker,
      a.sid,
      (select serial# from v$session where sid=a.sid) serial#,
      ' blocks ',
      (select osuser from v$session where sid=b.sid) blockee,
      b.sid, c.username username
    from v$lock a, v$lock b, v$session c
    where a.block = 1
    and b.request > 0
    and a.id1 = b.id1
    and a.id2 = b.id2
    and b.sid = c.sid

Kill session :

SQL> alter system kill session 'sid,serial#';

 

 

*********************************************************************************************************************
Also Check : http://aliimmam.com/locking-and-unlocking-tables-in-oracle/
Also Check : http://aliimmam.com/forms-could-not-reserve-record-2-tries-keep-trying/
Note : Please not do make backups before using these queries and also confirm them yourself or by aother means as well.

*********************************************************************************************************************

Share