- Try to insert the new row into TABLE
- While the insertion fails because a duplicate-key error (primary key)
- DELETE conflicting row that had duplicate key value from TABLE
- Try again to INSERT the new row into the TABLE
REPLACE INTO F SELECT * FROM T;
REPLACE INTO F(a, b, c) SELECT a, b, c FROM T;
REPLACE INTO become more efficient from ” DELETE FROM… INSERT INTO…”
but slower than UPDATE .
Use “INSERT … ON DUPLICATE KEY UPDATE…” if you’re looking a single unique column table (Primary Key).