You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doc: clarify NULLS NOT DISTINCT use in unique indexes
indexes-unique.html mentioned nothing about the availability of NULLS NOT
DISTINCT to modify the NULLs-are-not-equal behavior of unique indexes.
Add this to the synopsis and clarify what it does regarding NULLs.
Author: David Gilman, David Rowley
Reviewed-by: Corey Huinker
Discussion: https://postgr.es/m/CALBH9DDr3NLqzWop1z5uZE-M5G_GYUuAeHFHQeyzFbNd8W0d=Q@mail.gmail.com
Backpatch-through: 15, where NULLS NOT DISTINCT was added
Copy file name to clipboardExpand all lines: doc/src/sgml/indices.sgml
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -664,16 +664,18 @@ CREATE INDEX test3_desc_index ON test3 (id DESC NULLS LAST);
664
664
Indexes can also be used to enforce uniqueness of a column's value,
665
665
or the uniqueness of the combined values of more than one column.
666
666
<synopsis>
667
-
CREATE UNIQUE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> (<replaceable>column</replaceable> <optional>, ...</optional>);
667
+
CREATE UNIQUE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> (<replaceable>column</replaceable> <optional>, ...</optional>) <optional> NULLS <optional> NOT </optional> DISTINCT </optional>;
668
668
</synopsis>
669
669
Currently, only B-tree indexes can be declared unique.
670
670
</para>
671
671
672
672
<para>
673
673
When an index is declared unique, multiple table rows with equal
674
-
indexed values are not allowed. Null values are not considered
675
-
equal. A multicolumn unique index will only reject cases where all
676
-
indexed columns are equal in multiple rows.
674
+
indexed values are not allowed. By default, null values in a unique column
675
+
are not considered equal, allowing multiple nulls in the column. The
676
+
<literal>NULLS NOT DISTINCT</literal> option modifies this and causes the
677
+
index to treat nulls as equal. A multicolumn unique index will only reject
678
+
cases where all indexed columns are equal in multiple rows.
0 commit comments