🔙 ROLLBACK Command in SQL
Last Updated: January 2026
The ROLLBACK command is a TCL (Transaction Control Language) command used to undo changes made in the current transaction.
👉 It restores the database to the last committed state.
- Cancels INSERT, UPDATE, DELETE changes
- Reverts data to previous state
- Ends the current transaction
- Works only before COMMIT
Hinglish Tip 🗣: Agar changes galat ho jaayein aur unhe cancel karna ho, tab ROLLBACK use hota hai.
Basic ROLLBACK
ROLLBACK;
ROLLBACK with DML (Concept Flow)
START TRANSACTION;
UPDATE employees SET salary = 60000 WHERE emp_id = 2;
DELETE FROM employees WHERE emp_id = 3;
ROLLBACK;
After ROLLBACK:
- Salary update ❌
- Delete operation ❌
- Data returns to last COMMIT state
⚠️ Important Points About ROLLBACK
- Cannot undo COMMIT
- Does not work on DDL commands
- Clears current transaction
- Requires transaction-supported engine