Re: disallowing multiple NULLs in a unique constraint - Mailing list pgsql-general

From Tom Lane
Subject Re: disallowing multiple NULLs in a unique constraint
Date
Msg-id 9872.1076306232@sss.pgh.pa.us
Whole thread Raw
In response to disallowing multiple NULLs in a unique constraint  (David Garamond <lists@zara.6.isreserved.com>)
Responses Re: disallowing multiple NULLs in a unique constraint
List pgsql-general
David Garamond <lists@zara.6.isreserved.com> writes:
> SQL Server only allow one NULL in a unique constraint column (it's the
> unique index that does that, so the unique constraint behaves like that
> too). The question is, what is the best way to simulate that behaviour
> in Postgres?

The best way is to rewrite your app to not depend on nonstandard
semantics.  SQL Server is unquestionably violating the SQL spec here,
and it's not out of the question that Microsoft might realize that and
fix it, leaving you up the creek on that platform as well as Postgres.

Instead of using NULL in that fashion, perhaps you could choose a
non-null dummy value to use instead.

            regards, tom lane

pgsql-general by date:

Previous
From: Lincoln Yeoh
Date:
Subject: Re: Repost: postmaster growing to consume all memory
Next
From: Alex Satrapa
Date:
Subject: Re: query progress indicator