Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. mysql> describe account;
  2. +----------+------------------+------+-----+-------------------+-------------------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +----------+------------------+------+-----+-------------------+-------------------+
  5. | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
  6. | username | varchar(255) | NO | | NULL | |
  7. | ts | timestamp | YES | | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
  8. +----------+------------------+------+-----+-------------------+-------------------+
  9. 3 rows in set (0.01 sec)
  10.  
  11. mysql> select * from account;
  12. +----+----------+---------------------+
  13. | id | username | ts |
  14. +----+----------+---------------------+
  15. | 1 | John | 2019-06-14 14:42:59 |
  16. +----+----------+---------------------+
  17. 1 row in set (0.00 sec)
  18.  
  19. Isolation level is REPEATABLE READ
  20.  
  21. Client #1
  22. mysql> start transaction;
  23. Query OK, 0 rows affected (0.00 sec)
  24.  
  25. mysql> update account set username = 'Mary' where id = 1;
  26. Query OK, 1 row affected (0.00 sec)
  27. Rows matched: 1 Changed: 1 Warnings: 0
  28.  
  29. mysql> select * from account;
  30. +----+----------+---------------------+
  31. | id | username | ts |
  32. +----+----------+---------------------+
  33. | 1 | Mary | 2019-06-14 14:42:59 |
  34. +----+----------+---------------------+
  35. 1 row in set (0.00 sec)
  36.  
  37. Client #2
  38. mysql> start transaction;
  39. Query OK, 0 rows affected (0.00 sec)
  40.  
  41. mysql> select * from account;
  42. +----+----------+---------------------+
  43. | id | username | ts |
  44. +----+----------+---------------------+
  45. | 1 | John | 2019-06-14 14:42:59 |
  46. +----+----------+---------------------+
  47. 1 row in set (0.00 sec)
  48.  
  49. Client #1
  50. mysql> commit;
  51. Query OK, 0 rows affected (0.01 sec)
  52.  
  53. Client #2
  54. mysql> select * from account;
  55. +----+----------+---------------------+
  56. | id | username | ts |
  57. +----+----------+---------------------+
  58. | 1 | John | 2019-06-14 14:42:59 |
  59. +----+----------+---------------------+
  60. 1 row in set (0.00 sec)
  61.  
  62. mysql> commit;
  63. Query OK, 0 rows affected (0.00 sec)
  64.  
  65. mysql> select * from account;
  66. +----+----------+---------------------+
  67. | id | username | ts |
  68. +----+----------+---------------------+
  69. | 1 | Mary | 2019-06-14 14:42:59 |
  70. +----+----------+---------------------+
  71. 1 row in set (0.00 sec)
  72.  
  73. Isolation level is READ COMMITTED
  74.  
  75. mysql> select * from account;
  76. +----+----------+---------------------+
  77. | id | username | ts |
  78. +----+----------+---------------------+
  79. | 1 | Mary | 2019-06-14 14:42:59 |
  80. +----+----------+---------------------+
  81. 1 row in set (0.00 sec)
  82.  
  83. Client #1
  84.  
  85. mysql> start transaction;
  86. Query OK, 0 rows affected (0.00 sec)
  87.  
  88. mysql> update account set username = 'Joseph';
  89. Query OK, 1 row affected (0.00 sec)
  90. Rows matched: 1 Changed: 1 Warnings: 0
  91.  
  92. Client #2
  93.  
  94. mysql> start transaction;
  95. Query OK, 0 rows affected (0.00 sec)
  96.  
  97. mysql> select * from account;
  98. +----+----------+---------------------+
  99. | id | username | ts |
  100. +----+----------+---------------------+
  101. | 1 | Mary | 2019-06-14 14:42:59 |
  102. +----+----------+---------------------+
  103. 1 row in set (0.00 sec)
  104.  
  105. Client #1
  106.  
  107. mysql> select * from account;
  108. +----+----------+---------------------+
  109. | id | username | ts |
  110. +----+----------+---------------------+
  111. | 1 | Joseph | 2019-06-14 14:42:59 |
  112. +----+----------+---------------------+
  113. 1 row in set (0.00 sec)
  114.  
  115. mysql> commit;
  116. Query OK, 0 rows affected (0.01 sec)
  117.  
  118. Client #2
  119.  
  120. mysql> select * from account;
  121. +----+----------+---------------------+
  122. | id | username | ts |
  123. +----+----------+---------------------+
  124. | 1 | Joseph | 2019-06-14 14:42:59 |
  125. +----+----------+---------------------+
  126. 1 row in set (0.00 sec)
  127.  
  128. mysql> commit;
  129. Query OK, 0 rows affected (0.01 sec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement