Skip to content

Starting a transaction

Starting a transaction tells SQLite to stop saving your changes automatically and to hold them instead until you decide to keep or discard them. Start one whenever you are about to make several related changes and want the option to undo them as a group.

To start a transaction:

  1. Select the database in the tree panel on the left.
  2. Choose Transaction → Start Transaction from the main menu.

From now on, every data edit you make in the grid and every statement you run on the SQL tab becomes part of the transaction. Nothing is written permanently until you commit it — and if you change your mind, you can roll it back and leave the database untouched.

You can also begin a transaction from a script with the BEGIN command:

BEGIN TRANSACTION;

UPDATE customer SET City = 'New Orleans' WHERE CustNo = 1221;
UPDATE orders   SET ShipToCity = 'New Orleans' WHERE CustNo = 1221;

The keyword TRANSACTION is optional, so BEGIN; on its own does the same thing.

Tip

While a transaction is active, the remaining Transaction commands (Commit, Rollback, Savepoint) become enabled. That is a quick way to tell whether the selected database already has an open transaction.

See also: Committing a transaction · Rolling back a transaction