Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0d0aeb0

Browse files
committed
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
1 parent c1cc4e6 commit 0d0aeb0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/src/sgml/indices.sgml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,16 +664,18 @@ CREATE INDEX test3_desc_index ON test3 (id DESC NULLS LAST);
664664
Indexes can also be used to enforce uniqueness of a column's value,
665665
or the uniqueness of the combined values of more than one column.
666666
<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>;
668668
</synopsis>
669669
Currently, only B-tree indexes can be declared unique.
670670
</para>
671671

672672
<para>
673673
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.
677679
</para>
678680

679681
<para>

0 commit comments

Comments
 (0)