ROLLBACK
rolling back a transaction.
Overview
ROLLBACK discards changes in the current uncommitted transaction and releases related resources. It applies only to work that has not been committed, cannot undo an earlier committed transaction, and does not replace backups. Applications should roll back consistently after validation failures or exceptions to avoid partially completed business state.
Basic syntax
ROLLBACK;
Examples
ROLLBACK example
Roll back the tutorial transaction and show its reverted state, illustrating how uncommitted work is abandoned after an error.
Run result
| statement | effect | note |
|---|---|---|
| ROLLBACK | Undo uncommitted transaction changes; when a savepoint is named, roll back only to it. | Actual behavior also depends on the storage engine, isolation level, and session state. Test lock waits, concurrency, and failure recovery in the target MySQL environment. |
Common issues
Finish with COMMIT to persist changes or ROLLBACK to undo them; do not leave transactions open.
No. Transactions protect operation consistency, while backups support disaster recovery.
Uncommitted work may retain locks, so keep transactions short and access resources in a consistent order.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.