Skip to content
Commitpedia
Log in Join & edit

What is a transaction?

A transaction groups several database changes so they all happen together or not at all, keeping the data consistent.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of What is a transaction?: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
1 min

A transaction is a bundle of database operations treated as one unit. Moving money is the classic picture: take 50 from account A and add 50 to account B. If the power fails after the first step, the money has vanished. Inside a transaction, either both steps are saved (commit) or neither is (rollback), so the books always balance.

Databases promise ACID properties for transactions: atomic, consistent, isolated and durable. Every web framework opens one around a request or a form submission, often without you noticing. You use them explicitly when several tables must change together, and you keep them short, because a long open transaction blocks other users from touching the same rows.

BEGIN;
UPDATE accounts SET balance = balance - 50 WHERE id = 1;
UPDATE accounts SET balance = balance + 50 WHERE id = 2;
COMMIT;

See also: What is a database? and What is SQL?

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

Repos in the wild

  • DuckDB duckdb/duckdb An in-process analytical SQL database. Run fast SQL directly on CSV, Parquet and JSON files, from the command line or inside Python and other languages. GitHub
  • SQLite (official Git mirror) sqlite/sqlite The source tree of SQLite, the self-contained SQL database engine embedded in phones, browsers and countless applications, mirrored to GitHub by its developers. GitHub

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +880 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?