Skip to content
Theory · Transactions · lesson 1 of 11

BEGIN, COMMIT and ROLLBACK

A draft with the two lines of a transfer: a COMMIT arrow moves both into the ledger, a ROLLBACK arrow leads to the bin

In the coffee chain's app every customer has an account: they top it up and pay for coffee from it. Anna wants to send Boris 30 rubles. For the database that is two statements: one UPDATE takes 30 from Anna's account, a second UPDATE adds it to Boris's. What happens if the server goes down between them? The money leaves Anna and never arrives.

In this lesson

  • A transaction: all or nothing
  • ROLLBACK throws the draft away
  • Common mistake
  • Key points