What are practical differences between `REPLACE` and `INSERT … ON DUPLICATE KEY UPDATE` in MySQL?

前端 未结 8 1478
清酒与你
清酒与你 2020-11-28 06:59

What I need is to set the values of all the fields of a record with a particular key (the key is composite actually), inserting the record if there is no record with such a

8条回答
  •  佛祖请我去吃肉
    2020-11-28 07:33

    If you don't list all the columns, I think REPLACE will reset any unmentioned columns with their default values in the replaced rows. ON DUPLICATE KEY UPDATE will leave unmentioned columns unchanged.

提交回复
热议问题