📍 SAVEPOINT Command in SQL

Last Updated: January 2026


The SAVEPOINT command is a TCL (Transaction Control Language) command used to create a checkpoint inside a transaction.

👉 It allows you to roll back part of a transaction, not the whole transaction.

  • Marks a specific point in a transaction
  • Allows partial rollback
  • Gives fine-grained control over changes
  • Works only before COMMIT

Hinglish Tip 🗣: Transaction ke beech me checkpoint banana, taaki sirf wahi tak rollback ho — yahi SAVEPOINT hai.


Create a SAVEPOINT

SAVEPOINT savepoint_name;

Example:

SAVEPOINT sp1;

ROLLBACK TO SAVEPOINT

Rolls back changes up to a specific savepoint.

ROLLBACK TO savepoint_name;

Example

ROLLBACK TO sp1;
  • Changes made after sp1 are undone.
  • Changes before sp1 remain intact.

SAVEPOINT in Transaction Flow

START TRANSACTION;

INSERT INTO employees VALUES (4, 'Ravi', 40000);

SAVEPOINT sp1;

UPDATE employees SET salary = 45000 WHERE emp_id = 4;

ROLLBACK TO sp1;

COMMIT;

📌 Result:

  • INSERT ✅
  • UPDATE ❌
  • Data is saved after COMMIT

⚠️ Important Points About SAVEPOINT

  • Works only with DML commands
  • Savepoints are cleared after COMMIT
  • Multiple savepoints can exist
  • Names must be unique within transaction