mercredi 25 mars 2015

Different UNIQUE constraint when a column is null

So "null" in sqlite is not a fixed value. If there's a constraint that involves a column that is null, it will always be considered unique.


Is it possible to take null into account too? My table looks like this:



CREATE TABLE test(
parent INTEGER
name TEXT
UNIQUE(name, parent)
....


and I want



UNIQUE(name, parent)
UNIQUE(name) if parent is null

Aucun commentaire:

Enregistrer un commentaire