Find the Transaction Mistake
Find the Mistake Medium
Question
This transaction has a mistake. Find it:
Code
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
-- No COMMIT or ROLLBACK!
Hint
What happens if you never end a transaction?
Explanation
The transaction is never ended with COMMIT or ROLLBACK. This means the changes are not saved and the transaction holds locks indefinitely. Fix: add COMMIT; at the end to save the changes (or ROLLBACK; to undo them).
Related Resources
Related Lessons
- Transactions
Learn transaction completion.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.