Thursday, January 05, 2006

Nullable fields in a unique constraint, BAD

Can't have a unique constraint with a nullable field and treat that nullable as a "unique" value.

(Oracle) http://www.adp-gmbh.ch/ora/misc/integrity_constraints.html ,
http://www.techonthenet.com/oracle/unique.php

(Postgresql)http://www.postgresql.org/docs/8.1/interactive/indexes-unique.html

(MySQL5) http://dev.mysql.com/doc/refman/5.0/en/create-table.html

A UNIQUE index is one in which all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. The exception to this is that if a column in the index is allowed to contain NULL values, it can contain multiple NULL values. This exception does not apply to BDB tables, for which an indexed column allows only a single NULL.

No comments: