search

Home  >  Q&A  >  body text

mysql - 对同一个表同时更新2条记录,但更新不同字段,会不会造成数据丢失?

运营要求修改某条记录的权重,但用户参与的时候,会对另外一个字段更新,如果用户和运营的操作是同时进行的话,会不会导致前者或者后者更新丢失 ?

ringa_leeringa_lee2847 days ago768

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 15:25:33

    Let’s put it this way. When data is updated, a write lock is added. When another operation is to be written, it will enter waiting. until the write lock is released.

    reply
    0
  • 阿神

    阿神2017-04-17 15:25:33

    Updating different fields will not work, provided that each of your update statements only updates one field

    reply
    0
  • 迷茫

    迷茫2017-04-17 15:25:33

    No, make sure the where condition of update is correct

    reply
    0
  • Cancelreply