SQL ROLLBACK Command Explained | Transaction Control Language (TCL) Tutorial

Опубликовано: 14 Август 2026
на канале: Fratello Innotech
5
1

SQL - ROLLBACK COMMAND (TCL)
Definition

The ROLLBACK command is a Transaction Control Language (TCL) command used to undo or cancel all changes made during the current transaction before they are permanently saved. It restores the database to its previous state before the transaction began.

Syntax
ROLLBACK;
Steps to Use ROLLBACK Command
Step 1: Launch MySQLYog

Open MySQLYog and connect to the MySQL server.

Step 2: Select the Database

Choose the database where the transaction will be performed.

USE college_db;
Step 3: Start a Transaction

Begin a new transaction.

START TRANSACTION;
Step 4: Perform Database Operations

Insert, update, or delete records as required.

UPDATE student
SET city = 'Mumbai'
WHERE id = 1;
Step 5: Execute the ROLLBACK Command

Undo all changes made during the current transaction.

ROLLBACK;
Step 6: Verify the Records

Display the records to check whether the changes have been reverted.

SELECT * FROM student;
Step 7: Confirm the Result

Verify that the original data has been restored successfully.