[sqlite] Insert or Replace Trouble

2016-03-09 Thread R Smith
Apologies, it seems you got lots of replies explaining why, but I failed to mention how it would work. Try this in your code: CREATE TABLE messages (id numeric PRIMARY KEY); insert or replace into messages values (1); insert or replace into messages values (1); insert or replace into messages v

[sqlite] Insert or Replace Trouble

2016-03-09 Thread R Smith
On 2016/03/09 5:03 PM, Tilsley, Jerry M. wrote: > All, > > I'm trying to use the INSERT OR REPLACE syntax so that I don't have to worry > about duplicate entries without creating a trigger. Using the schema: > CREATE TABLE messages (id numeric); > > and using the SQL: > insert or replace into m

[sqlite] Insert or Replace Trouble

2016-03-09 Thread Clemens Ladisch
Tilsley, Jerry M. wrote: > CREATE TABLE messages (id numeric); > > insert or replace into messages values (1); > > Why does this result in multiple rows of the same value? INSERT OR REPLACE deletes any old row that would cause a UNIQUE constraint violation. Without a UNIQUE (or PRIMARY KEY) const

[sqlite] Insert or Replace Trouble

2016-03-09 Thread Hick Gunter
at mailinglists.sqlite.org] Im Auftrag von Tilsley, Jerry M. Gesendet: Mittwoch, 09. M?rz 2016 16:03 An: sqlite-users at mailinglists.sqlite.org Betreff: [sqlite] Insert or Replace Trouble All, I'm trying to use the INSERT OR REPLACE syntax so that I don't have to worry about duplica

[sqlite] Insert or Replace Trouble

2016-03-09 Thread Tilsley, Jerry M.
All, I'm trying to use the INSERT OR REPLACE syntax so that I don't have to worry about duplicate entries without creating a trigger. Using the schema: CREATE TABLE messages (id numeric); and using the SQL: insert or replace into messages values (1); Why does this result in multiple rows of th