Site icon TestingDocs.com

SQLite COMMIT Statement

Overview

Let’s learn about the SQLite COMMIT statement in this tutorial. The SQLite COMMIT statement terminates a transaction and saves all database changes. The COMMIT statement 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.

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;

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

SELECT * FROM emp;

 

SQLite Tutorials

SQLite tutorials on this website:

https://www.testingdocs.com/sqlite-database-tutorials/

For more information on SQLite, visit the official website:

https://www.sqlite.org

Exit mobile version