How to deal with concurrent updates in databases?

后端 未结 9 1727
名媛妹妹
名媛妹妹 2020-11-27 12:24

What\'s the common way to deal with concurrent updates in an SQL database ?

Consider a simple SQL schema(constraints and defaults not shown..) like

c         


        
9条回答
  •  孤独总比滥情好
    2020-11-27 13:11

    For the first scenario you could add another condition in the where-clause to make sure you won't overwrite changes made by a concurrent user. E.g.

    update credits set creds= 150 where userid = 1 AND creds = 0;
    

提交回复
热议问题