0% found this document useful (0 votes)
6 views

1. TCL Command

Unit 4 covers Transaction Control Language (TCL) commands used to manage transactions in a database, ensuring data integrity and error handling. Key commands include COMMIT to save changes, ROLLBACK to undo changes, and SAVEPOINT to create restore points within transactions. These commands are applicable only to DML operations like INSERT, UPDATE, and DELETE.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

1. TCL Command

Unit 4 covers Transaction Control Language (TCL) commands used to manage transactions in a database, ensuring data integrity and error handling. Key commands include COMMIT to save changes, ROLLBACK to undo changes, and SAVEPOINT to create restore points within transactions. These commands are applicable only to DML operations like INSERT, UPDATE, and DELETE.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit - 4 (Indexes, Views and Security)

 TCL Command

 Transaction control (Transaction Control language)


 A transaction is a unit of work that is performed against a database.
 A transaction is the propagation of one or more changes to the database.
 For example, if you are creating a record or updating a record or deleting a record
from the table then you are performing transaction on the table.
 It is important to control transactions to ensure data integrity and to handle
database errors.
 Practically you will club many SQL queries into a group and you will execute all of
them together as a part of a transaction.
 Transaction Control:
 There are following commands used to control transactions:
 COMMIT: to save the changes.
 ROLLBACK: to rollback the changes.
 SAVEPOINT: creates points within groups of transactions in which to
ROLLBACK
 SET TRANSACTION: Places a name on a transaction.
 Transactional control commands are only used with the DML commands INSERT,
UPDATE, and DELETE only.
 They cannot be used while creating tables or dropping them because these
operations are automatically committed in the database.
 COMMIT Command:
 The COMMIT command is the transactional command used to save changes
invoked by a transaction to the database.
 The COMMIT command saves all transactions to the database since the last
COMMIT or ROLLBACK command.
 The syntax for COMMIT command is as follows:
 COMMIT;
 ROLLBACK Command:
 A ROLLBACK does exactly the opposite of COMMIT.
 The ROLLBACK command is the transactional command used to undo
transactions that have not already been saved to the database.
 The ROLLBACK command can only be used to undo transactions since the last
COMMIT or ROLLBACK command was issued.
 The syntax for ROLLBACK command is as follows:
 ROLLBACK;

 SAVEPOINT Command:
 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.
 The syntax for SAVEPOINT command is as follows:
 SAVEPOINT SAVEPOINT_NAME;
 This command serves only in the creation of a SAVEPOINT among
transactional statements.
 The ROLLBACK command is used to undo a group of transactions.
 The syntax for rolling back to a SAVEPOINT is as follows:
 ROLLBACK TO SAVEPOINT_NAME;

You might also like