COMMIT makes your changes permanent; ROLLBACK undoes them. Together with SAVEPOINT, they give you an undo button for data changes — invaluable when updating production tables.
Key Points
- MySQL runs in autocommit mode by default — each statement commits instantly
- START TRANSACTION suspends autocommit until you COMMIT or ROLLBACK
- ROLLBACK undoes everything since the transaction began
- SAVEPOINT sp1 marks a checkpoint; ROLLBACK TO sp1 undoes partially
- DDL statements (CREATE, ALTER, TRUNCATE) auto-commit — they can't be rolled back
- Safe-update ritual: BEGIN → UPDATE → verify with SELECT → COMMIT
.png)