Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing Locks in Oracle 10

Tags:

I have an issue when trying to update a column value in sqlplus.

It basically wont complete and just hangs. I am wondering if there is anyway to remove locks in oracle by force?

I've noticed a table called v$locked_object which does contain an onject ID relevant to the issue I am having.

Hope I've explained this good enough.

Thanks in advance for any help!

like image 607
Thomas Pollock Avatar asked Dec 12 '12 17:12

Thomas Pollock


People also ask

How can delete lock in Oracle?

1) Bouncing the system can release the lock. 2) Using the v$session, v$lock and dba_objects and manually you could clear them up. 3) In case you are using 10g, you could use @lock to find out which block has the lock and @lock_ob to find out which user has locked the table.

How do I remove a database lock?

Type "Kill <session ID>" into the command prompt, and press "Enter." Replace "Session ID" with the session ID number you wrote down in Step 2. This kills the user's session and the SQL lock that was created.


1 Answers

This will exactly serve your purpose:

SELECT SESSION_ID FROM DBA_DML_LOCKS WHERE NAME = <TABLE_NAME>; 

Use the SESSION_ID to find the corresponding SERIAL# with this statement:

SELECT SID, SERIAL# FROM V$SESSION WHERE SID IN (     SELECT SESSION_ID FROM DBA_DML_LOCKS WHERE NAME = <TABLE_NAME> ); 

Locate the offending tuples SID, SERIAL# and release it like this:

ALTER SYSTEM KILL SESSION 'SID, SERIAL#'; 
like image 117
Mari Avatar answered Oct 03 '22 17:10

Mari