I'd like to understand the exact semantics of using "FOR UPDATE" in connection with "JOIN". Does it just lock all the rows that were effectively used to build the end result? Does it do something else?
From this topic:
http://postgresql.1045698.n5.nabble.com/Select-For-Update-and-Left-Outer-Join-td4363154.html
I understand there are some important differences between database implementations. However I'm not sure. I'm interested in behaviour of any popular RDBMS out there, however PostgreSQL in particular.
The UPDATE statement in SQL is used to update the data of an existing table in database. We can update single columns as well as multiple columns using UPDATE statement as per our requirement. UPDATE table_name SET column1 = value1, column2 = value2,...
Data modification side of DML language in T-SQL includes three statements used for modifying data in SQL Server and those are: INSERT, UPDATE, and DELETE.
The UPDATE statement has the following form: UPDATE table_name SET column_name = value [, column_name = value ...] [ WHERE condition]
The Syntax for SQL UPDATE Command The columns that you want to modify are listed after the SET statement and are equated to their new updated values. Commas separate these columns. The condition in the WHERE clause dictates which rows from the mentioned columns will be updated.
You've got it correct. In a "SELECT FOR UPDATE" with a JOIN, any rows that contribute to the returned rows will be locked. You can change this behavior by adding an "OF table_a" to the "FOR UPDATE" so that only the rows from table_a will be locked. You can read more about this in the Postgres docs here:
http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With