Skip to main content

COMMIT statement

Each statement within SurrealDB is run within its own transaction. If a set of changes need to be made together, then groups of statements can be run together as a single transaction, either succeeding as a whole, or failing without leaving any residual data modifications.

The COMMIT statement can be used to commit a set of statements within a transaction, ensuring that all data modifications become a permanent part of the database.

Statement syntax

SurrealQL Syntax

Example usage

The following query shows example usage of this statement.

-- Setup accounts
CREATE account:one SET balance = 135,605.16;
CREATE account:two SET balance = 91,031.31;
-- Move money
UPDATE account:one SET balance += 300.00;
UPDATE account:two SET balance -= 300.00;
-- Finalise all changes