Problem Statement
Which lock types best describe typical row-level reads and writes?
Explanation
Reads either take shared locks (blocking writers on those rows) or read MVCC versions without locking them. Writes need exclusive intent so concurrent writers do not conflict.
Lock names and hierarchy vary by engine, but the concept of shared versus exclusive is common.
Code Solution
SolutionRead Only
UPDATE inventory SET qty=qty-1 WHERE sku='X'; -- exclusive row lock
Practice Sets
This question appears in the following practice sets:
