---
title: "Transactions"
description: "A database transaction is a sequence of one or more operations that are executed as a single logical unit of work, either fully applied or fully rolled back."
canonical: "https://motherduck.com/glossary/transactions/"
related:
  - title: "DuckDB statements | MotherDuck Docs"
    url: "https://motherduck.com/docs/sql-reference/duckdb-sql-reference/duckdb-statements/"
  - title: "DuckLake: The Definitive Guide — Live Author Q&A with Matt Martin & Alex Monahan | MotherDuck"
    url: "https://motherduck.com/videos/ducklake-definitive-guide-oreilly-book/"
  - title: "Database Concepts | MotherDuck Docs"
    url: "https://motherduck.com/docs/concepts/database-concepts/"
---

# Transactions

> A database transaction is a sequence of one or more operations that are executed as a single logical unit of work, either fully applied or fully rolled back.

## Overview

A transaction groups multiple reads and writes into one atomic unit. If every statement in the transaction succeeds, the changes are committed and become permanent; if any statement fails, the whole transaction can be rolled back, leaving the database as if it never happened. This all-or-nothing behavior is what lets applications safely perform multi-step operations, like transferring money between two accounts, without ever leaving the data in a half-updated state.

## Transaction Control in SQL

Standard SQL exposes transactions through `BEGIN` (or `START TRANSACTION`), `COMMIT`, and `ROLLBACK`:

```sql
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;
```

If either `UPDATE` fails, issuing `ROLLBACK` instead of `COMMIT` undoes both changes. Most databases run in auto-commit mode by default, wrapping each individual statement in its own implicit transaction unless a transaction is explicitly opened.

## DuckDB Transactions

DuckDB supports the same `BEGIN TRANSACTION` / `COMMIT` / `ROLLBACK` syntax and gives every transaction a consistent snapshot of the database via MVCC (multi-version concurrency control). DuckDB combines MVCC with optimistic concurrency control: multiple writer threads can start transactions concurrently, and appends never conflict with each other, but two transactions that modify the same rows at the same time will cause one of them to fail with a transaction conflict at commit time rather than blocking and waiting for a lock. This design favors the read-heavy, bulk-write patterns typical of analytical workloads over the fine-grained row locking used by OLTP databases.
