In MySQL INSERT
- REPLACE INTO
- INSERT INTO .. ON DUPLICATE KEY UPDATE
Which SQL is Better?
Could you give me a advice?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depends what you’re doing with them.
REPLACE INTOis technically faster since it doesn’t have to do a read before updating (but that is mostly irrelevant), but I’ve felt thatINSERT INTO ... ON DUPLICATE KEY UPDATEis generally more clear as to what you want to do.Here is a short discussion in a blog.