File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Oracle/OAS and the fly likes How to find oracle table is locked or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "How to find oracle table is locked or not" Watch "How to find oracle table is locked or not" New topic

How to find oracle table is locked or not

Shaffic Mahaboobjan

Joined: May 10, 2012
Posts: 1
Hi ppl. I have a big doubt, can anyone tell me how to find the oracle table is locked or not? and if some client is already locked the table using 'select for update' clause, what could be the solution to release the lock or to avoid lock.
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Welcome to the Ranch, Shaffic!

I've moved your question to our Oracle forum, as it is much better suited for it than the general JDBC forum.

There are several performance and administration views that will allow you to find out details of the active locks. They are all documented here. It's a dense read, though. You might want to start with V$LOCK or DBA_LOCK (use index in that document). However, you need powerful privileges to access these views, which you probably won't be granted by a database administrator in production environments.

Also note that SELECT FOR UPDATE lock, or any other DML lock, only block writers, not readers. Consequently readers "avoid" these locks automatically and are never blocked (unlike some other databases where isolation level has to be adjusted to have readers avoid write-locks). There is no way for writers to avoid these locks.

To release the lock the transaction that holds it must be ended; if it is not ended by the process that holds it, the only other possibility I know of is to have a DBA kill the session that holds the lock.
I agree. Here's the link:
subject: How to find oracle table is locked or not
It's not a secret anymore!