Wednesday, March 14, 2012

How to identify and unlock table locks

/* 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
 

/* login as SYSDBA and kill blocking session */
alter
system kill session 'sid,serial#';

2 comments:

Unknown said...

brillant piece of information, I had come to know about your web-page from my friend hardkik, chennai,i have read atleast 9 posts of yours by now, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a million once again, Regards, Unlock Table Oracle


Anonymous said...

louis vuitton outlet, nike air max, polo ralph lauren outlet, ray ban sunglasses, louis vuitton outlet, cheap oakley sunglasses, prada handbags, ugg boots, louis vuitton, chanel handbags, air max, oakley sunglasses, tiffany jewelry, air jordan pas cher, uggs on sale, oakley sunglasses, louis vuitton, jordan shoes, tory burch outlet, sac longchamp, kate spade outlet, louboutin shoes, louboutin pas cher, burberry, longchamp outlet, replica watches, louis vuitton, ray ban sunglasses, nike outlet, michael kors, ray ban sunglasses, nike free, longchamp pas cher, nike roshe run, oakley sunglasses, louboutin outlet, nike air max, longchamp, tiffany and co, christian louboutin outlet, nike free, louboutin, prada outlet, ugg boots, gucci outlet, oakley sunglasses, replica watches, ralph lauren pas cher, polo ralph lauren outlet, longchamp outlet