This a plain file that contains the commands that can be used to replicate the
hands-on example "PSQL Transactions in Action".

Commands are wrapped in a blocks of ``` (according to Markdown:
https://en.wikipedia.org/wiki/Markdown; please use a Markdown viewer for proper
readability) and on top the description of the code is underline with `=======`.

## (0) Preparation
================================================================================

Create the `accounts` table and fill it with two bank accounts, `A` and `B`,
with a balance of `800` and `2.000`, respectively.

```
CREATE TABLE accounts(
  account TEXT NOT NULL,
  balance INTEGER NOT NULL
);

INSERT INTO accounts(account, balance) VALUES ('A', 800);
INSERT INTO accounts(account, balance) VALUES ('B', 2000);
```

## (1) Terminal 1
================================================================================
```
SELECT * FROM accounts;

BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE account = 'A'; // now 300
SELECT * FROM accounts;
```

## (2) Terminal 2
================================================================================
```
SELECT * FROM accounts; // still 800

BEGIN;
UPDATE accounts SET balance = balance + 1000 WHERE account = 'A';
```

## (3) Terminal 1
================================================================================
```
SELECT * FROM accounts;
UPDATE accounts SET balance = balance + 500 where account = 'B'; // now 2500
COMMIT;
SELECT * FROM accounts;
```

## (4) Terminal 2
================================================================================
```
COMMIT;
SELECT * FROM accounts;
```