REPLACE INTO table(column_list) VALUES(value_list);
- shorter form
INSERT OR REPLACE INTO table(column_list) VALUES(value_list);
For REPLACE to work properly, your table structure must have unique rows, be it a simple primary key or a unique index.
REPLACE deletes, then INSERT writes the record and triggers the INSERT trigger, if you have the setting. If you have an INSERT trigger, you may run into problems.
This is the work around. Speed not verified.
INSERT OR IGNORE INTO table (column_list) VALUES(value_list);
followed by
UPDATE table SET field=value,field2=value WHERE uniqueid='uniquevalue'
This method allows replacement without triggering.
Hariboo Nov 16 '16 at 15:38 2016-11-16 15:38
source share