Answer
A transaction groups SQL statements into one unit of work. • COMMIT makes its successful changes durable and visible according to isolation rules. • ROLLBACK discards its uncommitted changes. • Transactions help keep related changes consistent when an error occurs.
💡 SQL Example
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE account_id = 1;
UPDATE accounts SET balance = balance + 100 WHERE account_id = 2;
COMMIT;
Result
COMMIT
⚡ Quick Revision
A transaction commits all related changes together or rolls them back.