Insert or delete-and-insert based on unique key conflicts.
Section: insert, update, and delete
Replace a row using REPLACE
sql
sql
REPLACE INTO feature_flags (flag_key, flag_value) VALUES ('beta_ui', 'on');Explanation
`REPLACE` can have surprising semantics because it may delete the old row and insert a new one.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing insert, update, and delete
Upsert with ON DUPLICATE KEY UPDATE
Insert a row or update it when a unique key already exists.
Truncate a table
Remove all rows quickly and reset auto-increment counters.