REPLACE works exactly like INSERT, except that if an old
record in the table has the same value as a new record for a PRIMARY
KEY or a UNIQUE index, the old record is deleted before the new
record is inserted.
See also : [INSERT, ,INSERT].

Note that unless the table has a PRIMARY KEY or UNIQUE index,
using a REPLACE statement makes no sense. It becomes equivalent to
INSERT, because there is no index to be used to determine whether a new
row duplicates another.

Values for all columns are taken from the values specified in the
REPLACE statement.  Any missing columns are set to their default
values, just as happens for INSERT.  You can't refer to values from
the old row and use them in the new row.  It appeared that you could do this
in some old MySQL versions, but that was a bug that has been corrected.

To be able to use REPLACE, you must have INSERT and
DELETE privileges for the table.
