Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

EXPERIMENT-5

Queries on Controlling Data: Commit, Rollback, and Save point

Objective: To understand the concept of administrative commands

Theory:
COMMIT Command
COMMIT command is used to permanently save any transaction into the database.
When we use any DML command like INSERT, UPDATE or DELETE, the changes made by
these commands are not permanent, until the current session is closed, the changes made by
these commands can be rolled back.
To avoid that, we use the COMMIT command to mark the changes as permanent.
Syntax:

The syntax for the COMMIT command is as follows.

COMMIT;

ROLLBACK Command
This command restores the database to last commited state. It is also used
with SAVEPOINT command to jump to a savepoint in an ongoing transaction.
If we have used the UPDATE command to make some changes into the database, and realise that
those changes were not required, then we can use the ROLLBACK command to rollback those
changes, if they were not commited using the COMMIT command.
Syntax:

The syntax for a ROLLBACK command is as follows −

ROLLBACK;

SAVEPOINT Command
SAVEPOINT command is used to temporarily save a transaction so that you can rollback to that
point whenever required. A SAVEPOINT is a point in a transaction when you can roll the
transaction back to a certain point without rolling back the entire transaction.

Syntax:

The syntax for a SAVEPOINT command is as shown below.

SAVEPOINT SAVEPOINT_NAME;
This command serves only in the creation of a SAVEPOINT among all the transactional
statements. The ROLLBACK command is used to undo a group of transactions.

The syntax for rolling back to a SAVEPOINT is as shown below.

ROLLBACK TO SAVEPOINT_NAME;

PRACTICE:
PLEASE WRITE DOWN THE
OBSERVATION CONTENT HERE FROM
PRACITICE ONWARDS TO LAST PAGE i.e table
creation to savepoint

You might also like