Application of UPDATE and nowait in oracle

  • 2021-07-26 09:02:54
  • OfStack

1. UPDATE nowait applies the following scenario: Query a piece of data and open a database transaction on it. If the current data of the query is not locked, the result is returned correctly and the current data is locked, or if the current data of the query is already in a transaction, it is locked. However, an exception message is returned: prompt that the data is locked. SQL statement:

Sql code:
 
SELECT * 
FROM hold_mc_site_product_pic pic 
WHERE pic.id = 730127 FOR UPDATE nowait 

2. It is applied in the case of multi-thread concurrency. First, query out the data to be processed, and add a database-level lock, after processing, write to the database. Commit the transaction. It can effectively control the uniformity of data in concurrent situation.

Related articles: