REPLACE

This lesson discusses the REPLACE clause.

We'll cover the following...

REPLACE

REPLACE is much like the INSERT statement with one key difference: we can’t insert a row if a table already contains a row with the same primary key. However, REPLACE allows us the convenience of adding a row with the same primary key as an existing row in the table. Under the hood, REPLACE deletes the row and then adds the new row thereby maintaining the primary key constraint at all times. Sure, we can also use the UPDATE clause to achieve the same effect. However, REPLACE can be useful in automated scripts where it is not known ahead of time if a ...