Postgres Select For Share guide

A nice guide on how to do SELECT ... FOR SHARE and FOR UPDATE in Postgres

A regular select statement does not give you enough protection if you want to query data and make a change in the database related to it. Other transactions can update or delete the data you just queried. PostgreSQL offers additional select statements that lock on read and provide an extra layer of safety.

This article explores the select for share and select for update statements, locks that are created with these statements, and provide examples for using these two select statements.