Advertisement

09.13.2005 at 09:49AM PDT, ID: 21559936
[x]
Attachment Details

Locking a table with the "NO WAIT" option

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8
Tags:

oracle, wait, nowait

Is there a way to lock a table in Oracle 9/10 so that when another process tries to access/lock the table, the current lock tells the new process to not wait for the lock to lift?  I need to run a long update on a table (without taking the database down entirely) and I want any transactions that hit the table while the update is running to bounce with a "table is locked" type error.

According to the Oracle SQL Reference, it seems that "NO WAIT" option on a lock command only pertains to the lock being set, not any new incoming locks.

"Specify NOWAIT if you want Oracle to return control to you immediately if the specified table (or specified partition or subpartition) is already locked by another user. In this case, Oracle returns a message indicating that the table, partition, or subpartition is already locked by another user."

Example:
Update A locks table x (LOCK TABLE x IN EXCLUSIVE MODE) and starts updating.
Process B tries to perfom an update command (with a ROW SHARE lock).
Process B encounters the lock from A and returns a message (TABLE x LOCKED) instead of waiting for A's lock to lift.

If I read the SQL Ref. correctly, I would have to specify the "NO WAIT" option in the lock that Process B uses. I'm trying to do it the other way around since changing the sql statements on Processes B-etc. is not realistic for this one time data update.
Answered By: markgeer
Expert Since: 01/08/1999
Accepted Solutions: 2368
Computer Expertise: Advanced
markgeer has been an Expert for 10 years, during which he has posted 9834 comments and answered 2368 questions. markgeer is just one of 1067 experts in the Oracle Database Zone. 1 expert collaborated on this answer, which was graded an "A" by the asker.
 
 
20081119-EE-VQP-47