Last active
October 10, 2021 10:27
-
-
Save MartinThoma/bffe38ba5284f3f11189c8f605247e6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Transaction 2 Transaction 1 | |
# UPDATE balances SET balance = 500; | |
UPDATE 2 | |
# start transaction isolation level read committed; | |
START TRANSACTION | |
# SELECT SUM(balance) | |
FROM balances | |
WHERE id in ('Alice', 'Bob'); | |
sum | |
------ | |
1000 | |
(1 row) | |
SELECT transfer_out('Alice', 400); | |
SELECT transfer_out('Bob', 400); | |
SELECT * FROM balances; | |
id | balance | |
-------+--------- | |
Alice | 100 | |
Bob | 100 | |
# SELECT * | |
FROM balances | |
WHERE id in ('Alice', 'Bob'); | |
id | balance | |
-------+--------- | |
Alice | 100 | |
Bob | 100 | |
(2 rows) | |
# END; | |
COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment