The conflict action "replace" looks at ALL the PRIMARY KEY and UNIQUE constraints (express or implied) and deletes ALL the existing rows that prevent the candidate row from being inserted. As in "I don't care what it takes, I want THIS row to be in the table."
The other conflict actions just reflect the "level of panic" you associate with not being able to insert the row, from "don't care" (IGNORE) to "bloody hell" (ROLLBACK). -----Ursprüngliche Nachricht----- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Dominique Devienne Gesendet: Dienstag, 12. Juli 2016 14:39 An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Betreff: Re: [sqlite] insert or replace on PK and UNIQUE INDEX On Tue, Jul 12, 2016 at 2:31 PM, Richard Hipp <d...@sqlite.org> wrote: > On 7/12/16, Dominique Devienne <ddevie...@gmail.com> wrote: > > > > Is that normal or expected? > > The operation of REPLACE is defined here: > > https://www.sqlite.org/mark/lang_conflict.html?the+REPLACE+al*+current > +row#mark So the plural in "deletes pre-existing rows" explain that in my second example, with both the PK and NK where each point to different rows, both rows are first deleted, then the new row is inserted? I've never used "or replace" (this question comes from a different usage of SQLite than mine), and I guess they didn't read or understand the implications of the doc either. Thanks. Makes sense now, even though I still find it surprising a bit. Not what I'd naively assume without the benefit of reading the doc :) --DD _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: h...@scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users