tommo
tommo

Reputation: 1350

When selecting * FOR UPDATE in mysql using innodb does it lock all the results that match the query?

For example:

SELECT * FROM table1 ORDER BY id DESC FOR UPDATE

will this lock all the rows?

Upvotes: 0

Views: 29

Answers (1)

Barmar
Barmar

Reputation: 781761

Yes, it locks all the rows. From the documentation:

A SELECT ... FOR UPDATE reads the latest available data, setting exclusive locks on each row it reads. Thus, it sets the same locks a searched SQL UPDATE would set on the rows.

Upvotes: 2

Related Questions