views:

25

answers:

1

In MySQL INSERT

  1. REPLACE INTO
  2. INSERT INTO .. ON DUPLICATE KEY UPDATE

Which SQL is Better? Could you give me a advice?

+3  A: 

Depends what you're doing with them. REPLACE INTO is technically faster since it doesn't have to do a read before updating (but that is mostly irrelevant), but I've felt that INSERT INTO ... ON DUPLICATE KEY UPDATE is generally more clear as to what you want to do.

Here is a short discussion in a blog.

Travis Gockel