MySQL the SQL There are many extensions, some of which are handy, but some have performance problems after being misused, and there are some unintended side effects, such as REPLACE into .
MySQLwhen the data conflicts, it actually deletes the old record, and then writes the new record, which is usedREPLACE intoThe biggest mistake of all time, take the previous example, after the executionREPLACE into auto (k, v) VALUES (1, ' 1-1 ')after the new record is written, theExtrafield specifies the value, the original recordExtraThe value of the field is "Lost", which is usually not business-expected, and the more common requirement is actually when there isk=1record, just putvthe value of the field is updated to' 1-1 ', other unspecified fields remain intact, and the requirements are metMySQLdialect isINSERT into auto (k, v) VALUES (1, ' 1-1 ') on DUPLICATE KEY UPDATE v=values (v);
in view of this, many use REPLACE into the scenes that actually need to be INSERT into ... On DUPLICATE KEY UPDATE, use replaceinto sparingly ifyou understand the replace into behavior and side effects correctly.
Use MySQL's replace into carefully (reproduced)