vendredi 20 mars 2015

Unique constraint, but only if not null

Is it possible to make an unique constraint that only takes effect when a colum is not NULL?


Here's a example table:



CREATE TABLE tbl(
col1 TEXT,
col2 TEXT,
col3 TEXT,
UNIQUE(col1, col2, col3)
);


so if col2 is NULL, I want it to be treated like [col1, anything, col3]


Aucun commentaire:

Enregistrer un commentaire