ROLLBACK is a Transaction Control Language (TCL) command used in MySQL to undo changes made in the current transaction. It restores the database to the last committed state and is mainly used to prevent unwanted data changes.
INSERT, UPDATE, and DELETE operationsCOMMITCREATE or DROP auto-commitA transaction is a sequence of SQL statements executed as a single logical unit. If something goes wrong, ROLLBACK reverts all changes made during the transaction.
-- Start a new transaction
START TRANSACTION;
-- Insert a new record
INSERT INTO accounts (name, balance)
VALUES ('Rahul', 5000);
-- Undo the transaction
ROLLBACK;
ROLLBACK cancels the insert operationSHOW TABLE STATUSROLLBACK during testing and debuggingSAVEPOINT for partial rollbacksROLLBACK