sumana reddy

Posted on 21st June 2024|392 views


Postgresql Select For Update

When do we use the "Select... for update" statement in PostgreSQL?

1 answers
Athiq mohd

Posted on 21st June 2024| views

  1. The unprocessed data updated by some random part of applications will create a severe race-around condition so “for update” will prevent updates, deletes of rows and it also prevents other processes from a select for update clock. 
  2. Lock placed with the `FOR UPDATE` will not allow any other applications to read, update or delete the row. Other applications can read these rows only once the first application leaves the control.
  3. We can use “select...  for update”, but this only provides a lock for applications from reading or updating but “select... for update” is used to prevent other applications to access the database server concurrently in PostgreSQL database.
  4. “For update” statement blocks the transactions that try to update, read and delete the row for a particular interval until and unless the first transaction leaves the control on the database server.
  5. Then it unlocks them and now the transaction which was blocked can start using the server but cannot modify anything so that the next transaction can take control after it leaves.


Write your answer


Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Course *
Email *
Phone Number