Unique combination of fields in SQLite? Unique combination of fields in SQLite? python python

Unique combination of fields in SQLite?


CREATE TABLE (col1 typ              , col2 typ              , col3 typ              , CONSTRAINT unq UNIQUE (col1, col2, col3))

http://www.sqlite.org/lang_createtable.html


If the three columns really are the primary key then you can make a composite primary key:

create table t (    a text not null,    b text not null,    c text not null,    -- and whatever other columns you have...    primary key (a, b, c))

If any of your three columns can be NULL then you'd want to get with Cade's unique constraint instead.