null
-able columns in unique constraints (T591)Unique constrains accept an optional nulls distinct
modifier to specify that one null
value does not rule out other null
values in the same column of the constraint.
CREATE TABLE … (
…,
UNIQUE NULLS DISTINCT (…)
)
The default null treatment of unique constraints is implementation defined. Note that nulls not distinct
unique constraints may still treat null
values as distinct from each other for rows where all constraint columns are null
.0
null
-able columns in unique constraints (T591)null
null
The nulls distinct
specification is part of the optional feature F292, “UNIQUE null treatment”.
Note that SQL:2016 specifies the behaviour of nulls distinct
as the only way to cope with null
values in unique constraints. In the mentioned draft the default behaviour is implementation defined.
You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Twitter or RSS to gradually catch up and to keep modern-sql.com on your radar.
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »
CD 9075-2:202x(E), 4.25.3.2 Unique constraints (in particular NOTE 52).