ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

MySQL Relational Database Tutorial• 6 min read

ACID Transactions & Row-Level Locking

Guarantee bank-grade data integrity with ACID transactions, explicit COMMIT / ROLLBACK, and row-level locking.

The Four Pillars of ACID in InnoDB

Atomicity: All operations succeed, or all are rolled back. No partial writes.
Consistency: Constraints and foreign keys are never violated.
Isolation: Concurrent transactions cannot observe each other's intermediate uncommitted states.
Durability: Once committed, writes survive system crashes via the write-ahead redo log.
Bank Transfer Transaction with Rollback Protection
START TRANSACTION;

-- Deduct from Account A
UPDATE Accounts SET Balance = Balance - 250.00 WHERE AccountID = 101;

-- Credit Account B
UPDATE Accounts SET Balance = Balance + 250.00 WHERE AccountID = 202;

-- Check invariants and finalize
COMMIT;
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which SQL statement undoes all modifications made within an active uncommitted transaction block?