Mysql for update

Environment: mysql 5.7
transaction isolation level repeatable read

The current record of

table is as follows:
clipboard.png

:
clipboard.png

: id = 2
clipboard.png

:
clipboard.png

SQL
clipboard.png


clipboard.png


clipboard.png


clipboard.png

my question is: why does my session need to be submitted again in order to view the updated data of session II?

No for update. Is to simply open two transactions. Session 2 updates the data and commits the transaction. Session 1 commits the transaction and looks at the data. It is

that you can see the data updated by session 2.
Mar.10,2021

whether changes can be seen during a transaction session is related to the isolation level of the transaction.

see the official documentation:
https://dev.mysql.com/doc/ref.

by default, REPEATABLE READ, is readable repeatedly, that is, multiple reads during a transaction return the same result.

BTW:
the four isolation levels defined by mysql do not have repetable commit this.

there is only

on the official website.

level:

   REPEATABLE READ
   READ COMMITTED
   READ UNCOMMITTED
   SERIALIZABLE

Menu