Sqlite

SQLite COMMIT Statement

SQLite COMMIT Statement

In this tutorial, you will learn about the SQLite COMMIT statement. The COMMIT statement terminates a transaction and saves all database changes. It saves all transactions to the database since the last COMMIT or ROLLBACK statement.

Syntax

The general syntax of the statement is as follows:

COMMIT;

There are no additional clauses or options to the statement.

The BEGIN TRANSACTION initiates the transaction. If all the transaction statements are successfully completed, the COMMIT statement saves the changes to the database.

SQLite COMMIT Example

The following transaction updates two records of the emp table.

BEGIN TRANSACTION;
UPDATE emp SET salary = 5000 WHERE empno = 1;
UPDATE emp SET salary = 5500 WHERE empno = 6;
COMMIT;

SQLite COMMIT Statement

The COMMIT statement saves the changes made by the transaction to the database.

SELECT * FROM emp;

SQLite After Transaction Update

 

 

SQLite Tutorials

SQLite tutorials on this website: