Thursday 23 February 2017

How to find locked tables in Oracle DB

Below are the queries to find Locked Rows in Oracle DB tables, It will show you all the tables locked, to find your table un-comment  the condition in the query and enter your table name in CAPS :).

For RAC DB :- 

SELECT c.owner,
       c.object_name,
       c.object_type,
       b.sid,
       b.serial#,
       b.status,
       b.osuser,
       b.machine
  FROM gv$locked_object a, gv$session b, dba_objects c
 WHERE     b.sid = a.session_id
       AND a.object_id = c.object_id
--       AND c.object_name = &p_object_name


For Standalone DB :-

SELECT c.owner,
       c.object_name,
       c.object_type,
       b.sid,
       b.serial#,
       b.status,
       b.osuser,
       b.machine
  FROM v$locked_object a, v$session b, dba_objects c
 WHERE     b.sid = a.session_id
       AND a.object_id = c.object_id
--       AND c.object_name = &p_object_name

No comments:

Post a Comment