Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Transaction Control Language (TCL)

Transaction Control Language (TCL) instructions are used to handle database transactions. These are used to keep track of the modifications that DML statements make. It also allows you to organise statements into logical transactions. TCL commands help a user manage all the transactions taking place in a database.

In this article, we will dive deeper into the Transaction Control Language (TCL) according to the GATE Syllabus for (Computer Science Engineering) CSE. Keep reading ahead to learn more.

Table of Contents

What is Transaction Control Language (TCL)?

In the database, Transaction Control Language (TCL) commands are used to govern transactions. This command is used to manage changes to DML statements. TCL allows you to create logical transactions by combining your statements. Read more on the commands and transactions in TCL.

Some of the TCL commands are listed below:

COMMIT Command:

This command is used to save all the transactions in the DB.

Syntax:

COMMIT;

For Example,

UPDATE Student SET DOB=’2005-03-27’ WHERE Stu_Name=’Joey’;

COMMIT;

Thus, this example would insert the DOB in the given table, which has the name = Joey and then COMMIT these changes in the DB.

ROLLBACK Command:

The “rollback” term refers to the method of undoing changes. Thus, this command could only be used in order to reverse transactions that occurred since the last ROLLBACK or COMMIT command. All the modifications must be cancelled in case any SQL grouped statements produce a certain error.

Syntax:

ROLLBACK;

For Example:

UPDATE Student SET DOB=’2005-03-27’ WHERE Stu_Name=’Joe’;

ROLLBACK;

The example given above would insert the DOB in a table that has name = Joey and then ROLLBACK these changes in the DB. Thus, this type of operation would not create an impact on the table.

SAVEPOINT Command:

It is used to roll back a certain transaction to a certain point rather than the entire transaction.

Syntax:

SAVEPOINT Name_of_Savepoint;

This command is used exclusively among all transactions in order to create SAVEPOINT.

The ROLLBACK command is used to undo a set of given transactions.

Here is the syntax for the rollback to savepoint command in a code:

ROLLBACK TO Name_of_Savepoint;

Example:

SAVEPOINT S1; // created savepoint

DELETE FROM Student WHERE Stu_Name = ‘Joey’; //deleted

SAVEPOINT S2; // created savepoint

Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility CriteriaGATE 2023GATE Admit CardGATE SyllabusGATE Previous Year Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*