Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners

SQLite Code Factory online Help

Prev Return to chapter overview Next

BEGIN TRANSACTION

sql-statement ::=

BEGIN [TRANSACTION [name]] [ON CONFLICT conflict-algorithm]

sql-statement ::=

END [TRANSACTION [name]]

sql-statement ::=

COMMIT [TRANSACTION [name]]

sql-statement ::=

ROLLBACK [TRANSACTION [name]]

Beginning in version 2.0, SQLite supports transactions with rollback and atomic commit.

No changes can be made to the database except within a transaction. Any command that changes the database (basically, any SQL command other than SELECT) will automatically starts a transaction if one is not already in effect. Automatically started transactions are committed at the conclusion of the command.

 

Transactions can be started manually using the BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command. But a transaction will also ROLLBACK if the database is closed or if an error occurs and the ROLLBACK conflict resolution algorithm is specified. See the documentation on the ON CONFLICT clause for additional information about the ROLLBACK conflict resolution algorithm.

The optional ON CONFLICT clause at the end of a BEGIN statement can be used to changed the default conflict resolution algorithm. The normal default is ABORT. If an alternative is specified by the ON CONFLICT clause of a BEGIN, then that alternative is used as the default for all commands within the transaction. The default algorithm is overridden by ON CONFLICT clauses on individual constraints within the CREATE TABLE or CREATE INDEX statements and by the OR clauses on COPY, INSERT, and UPDATE commands.



Prev Return to chapter overview Next