×
>
<

Aptitude

SQL TCL Commands

TCL Commandss

TCL stands for Transaction Control Languages. These commands are used for maintaining consistency of the database and for the management of transactions made by the DML commands.

  • COMMIT
  • ROLLBACK
  • SAVEPOINT

TCL Commands

A Transaction is a set of SQL statements that are executed on the data stored in DBMS. Whenever any transaction is made these transactions are temporarily happen in database.So to make the changes permanent, we use TCL commands.

1.COMMIT

This command is used to save the data permanently. Whenever we perform any of the DDL command like -INSERT, DELETE or UPDATE, these can be rollback if the data is not stored permanently. So in order to be at the safer side COMMIT command is used.

Syntax
COMMIT;
2.ROLLBACK

This command is used to get the data or restore the data to the last savepoint or last committed state. If due to some reasons the data inserted, deleted or updated is not correct, you can rollback the data to a particular savepoint or if savepoint is not done, then to the last committed state.

Syntax
ROLLBACK;
2.SAVEPOINT

This command is used to save the data at a particular point temporarily, so that whenever needed can be rollback to that particular point.

Syntax
UPDATE NAME 
SET NAME= ‘Rossie’ 
WHERE marks= 70;

SAVEPOINT A;

INSERT INTO STUDENT 
VALUES (‘Zack’, 76);

Savepoint B;