Created
December 2, 2018 08:42
-
-
Save yfuruyama/4516fe4c9b94c1ceae34f8332dc4f5cd to your computer and use it in GitHub Desktop.
This file contains 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
+----------------------------------------------------------------------+----------------------------------------------------------------------+ | |
| tx1 | tx2 | | |
+----------------------------------------------------------------------+----------------------------------------------------------------------+ | |
| spanner> BEGIN; | | | |
| Query OK, 0 rows affected (0.05 sec) | | | |
| | | | |
| | spanner> BEGIN; | | |
| | Query OK, 0 rows affected (0.06 sec) | | |
| | | | |
| spanner> SELECT COUNT(*) as cnt FROM Accounts WHERE type = 'Saving'; | | | |
| +-----+ | | | |
| | cnt | | | | |
| +-----+ | | | |
| | 0 | | | | |
| +-----+ | | | |
| 1 rows in set (3.74 msecs) | | | |
| | | | |
| | spanner> SELECT COUNT(*) as cnt FROM Accounts WHERE type = 'Saving'; | | |
| | +-----+ | | |
| | | cnt | | | |
| | +-----+ | | |
| | | 0 | | | |
| | +-----+ | | |
| | 1 rows in set (2.52 msecs) | | |
| | | | |
| spanner> UPDATE Accounts SET type = 'Saving' WHERE UserId = 1; | | | |
| Query OK, 1 rows affected (0.52 sec) | | | |
| | | | |
| | spanner> UPDATE Accounts SET type = 'Saving' WHERE UserId = 2; | | |
| | Query OK, 1 rows affected (0.57 sec) | | |
| | | | |
| spanner> COMMIT; | | | |
| Query OK, 0 rows affected (0.52 sec) | | | |
| | | | |
| | spanner> COMMIT; | | |
| | ERROR: transaction was aborted | | |
| | | | |
| spanner> SELECT * FROM Accounts; | | | |
| +--------+---------+----------+ | | | |
| | UserId | Balance | Type | | | | |
| +--------+---------+----------+ | | | |
| | 1 | 1000 | Saving | | | | |
| | 2 | 1000 | Checking | | | | |
| | 3 | 1000 | Checking | | | | |
| +--------+---------+----------+ | | | |
| 3 rows in set (3.19 msecs) | | | |
| | | | |
+----------------------------------------------------------------------+----------------------------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment