Monday, April 15, 2019

TCL | TCL Commands | SQL Command

Transaction Control Language

In SQL, there are following types of TCL Commands. As under,
  • COMMIT
  • ROLLBACK
  • SAVE POINT
TCL commands are used to manage transaction in database. Like commit, rollback, save point.

These TCL commands are used to manage the changes made by DML commands.



COMMIT Command

Commit command used to save transaction into the database permanently.

Syntax :

commit ;

Example :

commit ;

ROLLBACK Command

Rollback command used to restores the database to last committed state.
It can be also used with SAVEPOINT command to jump to a save point in an ongoing database transaction.
Syntax :

ROLLBACK TO savepoint_name ;

Rollback command has one parameter

1) savepoint_name - This parameter used to provide name of  save point, which we want to rollback.

Example :

DELETE FROM Customer01 WHERE C_Id = 105;
ROLLBACK;

SAVEPOINT Command

Savepoint command used to set a point in a transaction. When you can roll the transaction back to a certain point without rolling back the entire transaction.

Syntax :

SAVEPOINT savepoint_name;

Example :

SAVEPOINT cust_1;


Recommanded :

Commit Command
Rollback Command
Savepoint Command

Note:

  • If we are use DML commands (INSERT, UPDATE, DELETE), the changes made by these commands are not permanent, until the current session is closed.

Previous Post
Next Post

post written by:

0 Comments: