Chapter 13. Transactions

A transaction is a sequence of one or more SQL statements executed as a single logical unit of work. The DBMS considers a transaction to be an indivisible, all-or-nothing proposition: It executes all the transaction’s statements as a group, or it executes none of them.

Canonical law requires me to illustrate the importance of transactions with a banking example. Suppose that a customer transfers $500 from her savings account to her checking account. This operation consists of two separate actions, executed sequentially:

1.
Decrement savings account by $500.
2.
Increment checking account by $500.

Figure 13.1 shows the two SQL statements for this transaction. Now imagine that the DBMS fails—power outage, system crash, ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.