Thursday, September 25, 2014

How to Identify the database session locking the tables

You can use the below command to find if any session has created lock on any database object:

Note: You need to have sys password to identify sessions which are causing the lock on tables and to kill those sessions.

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.owner='<>;

if above query returns any output, please use the below query to kill the session:

ALTER SYSTEM KILL SESSION 'SID,SERIAL';

Use the SID and SERIAL returned by the above query and execute the query.
I have used this query before running the OIM Bulk Load Utility.

No comments: