Actually, replace will delete any and all currently present rows that cause a 
UNIQUE violation.

asql> create temp table x (prim integer UNIQUE, seco integer UNIQUE, val 
integer);
asql> insert into x values (1,1,1);
rows inserted
-------------
1
asql> insert into x values (2,2,2);
rows inserted
-------------
1
asql> insert into x values (1,2,3);
Error: column seco is not unique
asql> replace into x values (1,2,3);
rows inserted
-------------
1
asql> select * from x;
prim        seco        val
----------  ----------  ----------
1           2           3

Gunter

-----Ursprüngliche Nachricht-----
Von: Sylvain Pointeau [mailto:sylvain.point...@gmail.com]
Gesendet: Mittwoch, 13. November 2013 15:16
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] SQL 2003 in sqlite

Hi,

> INSERT (OR REPLACE/IGNORE) INTO table1 SELECT * FROM table2 Do you
> have specific requirements for the UPDATE features of MERGE ?

the issue with "insert or replace" is that it will match on primary keys, 
additionally (I am not 100% sure) it deletes first the row to replace it.
we cannot update then only 1 column.

furthermore, the merge can delete as well, it does the join on the fields we 
want (not only PK), it is really wonderful.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


--------------------------------------------------------------------------
 Gunter Hick
Software Engineer
Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna, Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then delete this message from 
your system. Please do not copy it or use it for any purposes, or disclose its 
contents to any person as to do so could be a breach of confidence. Thank you 
for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to