It is giving you a syntax error because it is not allowed syntax. From your example I presume the schema is probably:
create table data_table (uid integer primary key autoincrement.
label string);
in which case primary key
implies unique
. But, since you allow auto-generation of uid
then you don't care what it's value is, you just don't want duplicate label
s in which case you actually care that label
be unique so tell it so:
create table data_table (uid integer primary key autoincrement,
label string unique on conflict fail);
which then works as expected:
sqlite> insert into data_table (label) values ("uk");
sqlite> insert into data_table (label) values ("uk");
Error: column label is not unique
sqlite> select * from data_table;
1|uk
Incidentally, if the names data_table
, uid
, and label
aren't example names for the purposes of this question then you should use more meaningful names as these are horribly uninformative.