diff options
author | David Rowley <drowley@postgresql.org> | 2023-04-20 23:52:36 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2023-04-20 23:52:36 +1200 |
commit | 94d73f9abdf13e6dd93d96d0e4b197479c8756de (patch) | |
tree | 2a0a70ec6e471daf3c6d57ccd145f87588b246f1 | |
parent | 62b22caa5531da8f6498f09f15ac0f09c95b1459 (diff) | |
download | postgresql-94d73f9abdf13e6dd93d96d0e4b197479c8756de.tar.gz postgresql-94d73f9abdf13e6dd93d96d0e4b197479c8756de.zip |
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
-rw-r--r-- | doc/src/sgml/indices.sgml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml index 0c3fcfd62f8..55122129d58 100644 --- a/doc/src/sgml/indices.sgml +++ b/doc/src/sgml/indices.sgml @@ -664,16 +664,18 @@ CREATE INDEX test3_desc_index ON test3 (id DESC NULLS LAST); 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. <synopsis> -CREATE UNIQUE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> (<replaceable>column</replaceable> <optional>, ...</optional>); +CREATE UNIQUE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> (<replaceable>column</replaceable> <optional>, ...</optional>) <optional> NULLS <optional> NOT </optional> DISTINCT </optional>; </synopsis> Currently, only B-tree indexes can be declared unique. </para> <para> 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 + <literal>NULLS NOT DISTINCT</literal> 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. </para> <para> |