开发者

Best approach to INSERT ... ON DUPLICATE KEY UPDATE

What would you say is an effective and perhaps a robust approach to doing

INSERT ... ON DUPLICATE KEY UPDATE

Some has argued "REPLACE is bad because it first deletes the duplicate, then inserts a replacement. INSERT/ON DUPLICATE first开发者_StackOverflow checks then does an update if it finds a match. This is a big difference."

Guys what do you think? point us on the right direction.


I'm using INSERT ON DUPLICATE KEY for 8 years already - and never had any issues with it. I call it "transactions for poor people" among my friends. Of course it's a joke, but the important point this - this operation is atomic


Use REPLACE only if you need a newly generated surrogate key, imo. Otherwise, on duplicate gives you more granular control of value changes and is more explicit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜