On Wed, Mar 09, 2011 at 11:37:46PM +0100, Armin Kunaschik scratched on the wall:
> On Wed, Mar 9, 2011 at 11:28 PM, Igor Tandetnik <itandet...@mvps.org> wrote:

> > INSERT OR REPLACE is indistinguishable from a DELETE followed by INSERT.

> Is it really DELETE and INSERT internally?

  Yes and no.  "REPLACE" alters the conflict resolution on UNIQUE
  constraints.  In all cases, the new row is INSERTed.  In the case of
  a REPLACE, if the INSERT would cause a UNIQUE constraint violation
  than any and all rows that are part of the conflict are first
  deleted before the new row is INSERTed.  In some situations a single
  INSERT OR REPLACE can actually cause multiple existing rows to be
  deleted before the new row is inserted.

  So it is always an INSERT, but sometimes the INSERT triggers one or
  more internal DELETEs first.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to