select for update

August 30, 2011 | By

sql tips, sql, select statement

 

 

 

 

Hi friends,

Today we discuss about SELECT FOR UPDATE characteristics.

By default, the Oracle RDBMS locks rows as they are changed by any update statement. To lock all rows in result set,  use the for update clause in your select statement when you open the cursor, instead of when you change the data. Using the FOR UPDATE clause does not necessitate you to essentially construct changes to the data; it merely locks the rows when opening the cursor. These locks are released on the next commit or rollback. As always, these row locks don’t affect other select statements unless they, too, are FOR update. The FOR UPDATE clause is appended to the end of the SELECT statement and has following syntax.

Command Syntax:

select from … for update [column reference] [NOWAIT];

 

Where column reference is a comma-delimited list of columns that appear in select  clause. The NOWAIT keyword tells the RDBMS to not wait for other blocking locks to be released. The default is to wait forever and it is more problematic.

Generally, SELECT FOR UPDATE is the best solution for blocking lock problem. But it is not good for every time.

A new Discussion Board of Oracle is established by Dbametrix for helping and give assistance for fresher Oracle job, how to earn money and Oracle troubleshooting. Kindly join and share the knowledge.

Thanks and regards,

Expert Database Administration

Online Oracle courses

Latest IT news

 

 

Be Sociable, Share!

Tags: , ,

Category: discussion board, oracle database, oracle utilities, software, sql, technology, tips

Comments are closed.