Module 4

MySQL Transactions, Isolation & Locking

20 mins read

Lesson 1: Transactions & Locking

1.1 START TRANSACTION & COMMIT

Managing atomic database state transitions with START TRANSACTION, COMMIT, and ROLLBACK.

MYSQL
START TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;
UPDATE accounts SET balance = balance + 100 WHERE account_id = 2;
COMMIT;