Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find oracle table is locked or not

 
Shaffic Mahaboobjan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic