REPLACE INTO
Warning
Currently, mixing column-oriented tables and row-oriented tables in a single transaction is supported only if the transaction performs read operations; no writes are allowed. Support for read-write transactions involving both table types is under development.
If a write transaction includes both types of tables, it fails with the following error: Write transactions between column and row tables are disabled at current time
.
Saves data to a table, overwriting the rows based on the primary key. If the given primary key is missing, a new row is added to the table. If the given PRIMARY_KEY
exists, the row is overwritten. The values of columns not involved in the operation are replaced by their default values.
Note
Unlike INSERT INTO
and UPDATE
, the queries UPSERT INTO
and REPLACE INTO
don't need to pre-fetch the data, hence they run faster.
Examples
-
Setting values for
REPLACE INTO
usingVALUES
.REPLACE INTO my_table (Key1, Key2, Value2) VALUES (1u, "One", 101), (2u, "Two", 102); COMMIT;
-
Fetching values for
REPLACE INTO
using aSELECT
.REPLACE INTO my_table SELECT Key AS Key1, "Empty" AS Key2, Value AS Value1 FROM my_table1; COMMIT;