Indexes can also be used to enforce uniqueness of a column's value,
or the uniqueness of the combined values of more than one column.
-CREATE UNIQUE INDEX name ON table (column , ...);
+CREATE UNIQUE INDEX name ON table (column , ...) NULLS NOT DISTINCT ;
Currently, only B-tree indexes can be declared unique.
When an index is declared unique, multiple table rows with equal
- indexed values are not allowed. Null values are not considered
- equal. A multicolumn unique index will only reject cases where all
- indexed columns are equal in multiple rows.
+ indexed values are not allowed. By default, null values in a unique column
+ are not considered equal, allowing multiple nulls in the column. The
+ NULLS NOT DISTINCT option modifies this and causes the
+ index to treat nulls as equal. A multicolumn unique index will only reject
+ cases where all indexed columns are equal in multiple rows.