pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Documentation discrepancy UNIQUE NULLS NOT DISTINCT
2+ messages / 2 participants
[nested] [flat]

* Documentation discrepancy UNIQUE NULLS NOT DISTINCT
@ 2023-01-19 22:41  Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Adrian Klaver @ 2023-01-19 22:41 UTC (permalink / raw)
  To: pgsql-general

 From here:

https://www.postgresql.org/about/featurematrix/detail/392/

UNIQUE NULLS NOT DISTINCT

By default, NULL values are not treated as distinct entries. Specifying 
NULLS NOT DISTINCT on unique indexes / constraints will cause NULL 
values to be treated distinctly.


 From here:

https://www.postgresql.org/docs/current/sql-createindex.html

NULLS DISTINCT
NULLS NOT DISTINCT

     Specifies whether for a unique index, null values should be 
considered distinct (not equal). The default is that they are distinct, 
so that a unique index could contain multiple null values in a column.

and here:

https://www.postgresql.org/docs/current/sql-createtable.html

For the purpose of a unique constraint, null values are not considered 
equal, unless NULLS NOT DISTINCT is specified.

-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Documentation discrepancy UNIQUE NULLS NOT DISTINCT
@ 2023-01-19 22:51  David G. Johnston <david.g.johnston@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2023-01-19 22:51 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general

On Thu, Jan 19, 2023 at 3:41 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

>  From here:
>
> https://www.postgresql.org/about/featurematrix/detail/392/
>
> UNIQUE NULLS NOT DISTINCT
>
> By default, NULL values are not treated as distinct entries. Specifying
> NULLS NOT DISTINCT on unique indexes / constraints will cause NULL
> values to be treated distinctly.
>
>
>  From here:
>
> https://www.postgresql.org/docs/current/sql-createindex.html
>
> NULLS DISTINCT
> NULLS NOT DISTINCT
>
>      Specifies whether for a unique index, null values should be
> considered distinct (not equal). The default is that they are distinct,
> so that a unique index could contain multiple null values in a column.
>
> and here:
>
> https://www.postgresql.org/docs/current/sql-createtable.html
>
> For the purpose of a unique constraint, null values are not considered
> equal, unless NULLS NOT DISTINCT is specified.
>
>
I think saying that NULLs are distinct by default is the better way to
present this.  The documentation disagrees on the verbiage but both state
the same truth; the feature matrix page needs to be fixed.

David J.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2023-01-19 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 22:41 Documentation discrepancy UNIQUE NULLS NOT DISTINCT Adrian Klaver <adrian.klaver@aklaver.com>
2023-01-19 22:51 ` David G. Johnston <david.g.johnston@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox