Created
October 10, 2021 10:30
-
-
Save MartinThoma/10bde6346b5212cb54e5ecd9ab19fabd 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
# UPDATE balances SET balance = 500; | |
UPDATE 2 | |
# start transaction isolation level repeatable read; | |
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 | 500 | |
Bob | 500 | |
(2 rows) | |
# END; | |
COMMIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment