I think the point is that attempting to create the unique index should fail 
(with an error) and the index not be created rather than creating a unique 
index with duplicates (or whatever it is doing) causing subsequent queries to 
return incorrect results.

>On Wed, 30 Jul 2014 09:10:29 +0400
>Pavel Pimenov <pavel.pime...@gmail.com> wrote:
>
>> CREATE TABLE fly_hash_block(tth_id integer PRIMARY KEY NOT NULL, tth
>> number NOT NULL);
>> INSERT INTO fly_hash_block VALUES(1,1);
>> INSERT INTO fly_hash_block VALUES(2,2);
>> INSERT INTO fly_hash_block VALUES(3,2);
>> *CREATE UNIQUE INDEX iu_fly_hash_block_tth ON fly_hash_block(tth);*
>
>Not an answer if the table already exists, but a better solution would
>be to constrain the table:
>
>sqlite> CREATE TABLE fly_hash_block(
>               tth_id integer PRIMARY KEY NOT NULL,
>               tth number not null UNIQUE);
>sqlite> INSERT INTO fly_hash_block VALUES(1,1);
>sqlite> INSERT INTO fly_hash_block VALUES(2,2);
>sqlite> INSERT INTO fly_hash_block VALUES(3,2);
>Error: column tth is not unique
>sqlite>
>
>--jkl
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to