do database transactions prevent other users from interfering with it

后端 未结 6 2001
失恋的感觉
失恋的感觉 2021-01-01 04:25

Suppose I do (note: the syntax below is probably not correct, but don\'t worry about it...it\'s just there to make a point)

Start Transaction
INSERT INTO tab         


        
6条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 05:08

    Interfere is a fuzzy word when it comes to SQL database transactions. What rows a transaction can see is determined in part by its isolation level.

    Hence the goal of the select is to get ALL info from the table that just got inserted by the preceding insert and ONLY by the preceding INSERT...

    Preceding insert is a little fuzzy, too.

    You probably ought to COMMIT the insert in question before you try to read it. Otherwise, under certain conditions not under your control, that transaction could be rolled back, and the row with id=100 might not actually exist.

    Of course, after it's committed, other transactions are free to change the value of "id", of "value", or both. (If they have sufficient permissions, that is.)

提交回复
热议问题