On May 7, 2012, at 3:44 PM, Pavel Ivanov wrote:

> It's a well documented feature: "or replace" means "if you see
> constraint violations while updating please delete all violating rows
> and then proceed with update"

Yep, I'm familiar with the ON CONFLICT clause. Or I thought I was as I haven't 
fully internalize its dramatic implication in relation to update statements.

For example, delete all your rows but one with one easy update statement:

sqlite> create table numbers(num int unique );
sqlite> insert into numbers( num ) values( 1 );
sqlite> insert into numbers( num )  values( 2 );
sqlite> insert into numbers( num )  values( 3 );
sqlite> insert into numbers( num )  values( 4 );
sqlite> insert into numbers( num )  values( 5 );
sqlite> select count( * ) from numbers;
5
sqlite> update or replace numbers set num = 1;
sqlite> select count( * ) from numbers;
1

Oh, well… caveat emptor...
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to