Re: disallowing multiple NULLs in a unique constraint

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: disallowing multiple NULLs in a unique constraint
Date: 2004-05-12 11:00:06
Message-ID: 200405121300.07216.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am Montag, 9. Februar 2004 06:06 schrieb David Garamond:
> 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? Can a CHECK constraint does that? Will a trigger with
> SELECT count(*) ... WHERE f IS NULL be too slow if the table is large?

You can time that yourself (but I suspect it won't be pretty), but I think
that you're going to have all kinds of other problems if you base your
database schema on the assumption that NULL = NULL. Better fix the
application.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Kelly 2004-05-12 11:03:40 OT: Dup mails
Previous Message Kris Jurka 2004-05-12 10:13:45 Re: query progress indicator