Skip to main content
Version: 1.x

CANCEL 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 CANCEL statement can be used to cancel a set of statements within a transaction, reverting or rolling back any data modification made within the transaction as a whole.

Statement syntax

SurrealQL Syntax
CANCEL [ TRANSACTION ];

Example usage

The following query shows example usage of this statement.

BEGIN TRANSACTION;
-- Setup accounts
CREATE account:one SET balance = 135605.16;
CREATE account:two SET balance = 91031.31;
-- Move money
UPDATE account:one SET balance += 300.00;
UPDATE account:two SET balance -= 300.00;
-- Rollback all changes
CANCEL TRANSACTION;