hard20 pts · first answer countstransactionsrow-lockssql
FOR UPDATE on a join locks too much
This query should lock only the order row, but it also locks the customer row and blocks unrelated updates to customers. How do you fix it?
SELECT o.*, c.name FROM orders o JOIN customers c ON c.id = o.customer_id WHERE o.id = 101 FOR UPDATE;
Discussion 0
Join free to post in the discussion.
Related questions
- Purpose of a primary keyDatabase Administrator
- Durability in ACIDDatabase Administrator
- INNER JOIN vs LEFT JOINDatabase Administrator
- DELETE vs TRUNCATEDatabase Administrator
- Filtering rows where a value is NULLDatabase Administrator
- COUNT(*) vs COUNT(column)Database Administrator
- What a foreign key enforcesDatabase Administrator
- WHERE vs HAVINGDatabase Administrator