picoSQL - Language reference manual


REPLACE (rel. 1.2)


Syntax:

Format 1:

REPLACE INTO table-name [(column-name [, column-name]...)]
VALUES (expression |NULL [, expression | NULL] ...)

Format 2:

REPLACE INTO table-name [(column-name [, column-name]...)] subquery


Purpose:

Allows to insert or rewrite one or more rows in the named table.


See also:

INSERT, DELETE


Description:


This command is simular to the INSERT statement, the difference is that if the row insertion cannot be done because of one (and only one) unique index duplication, REPLACE rewrite the full row. From a logical point of view REPLACE is equivalent to execute a DELETE statement based on the first unique index and then an INSERT statement. However, the REPLACE command is atomic and much more efficient than executin DELETE and INSERT statement. You can get a duplicate index error only if the table has more than one unique index and if the REPLACE cause the duplication of an index successive the first one.


Index Previous Next