Re: Adding UNIQUE constraint on NULL column - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Adding UNIQUE constraint on NULL column
Date
Msg-id 20050113171658.GB13594@wolff.to
Whole thread Raw
In response to Adding UNIQUE constraint on NULL column  (Dave Smith <dave.smith@candata.com>)
List pgsql-general
On Thu, Jan 13, 2005 at 09:01:08 -0500,
  Dave Smith <dave.smith@candata.com> wrote:
> I am trying to add a unique constraint on a column that can be null. The
> documentation states that null is treated as non equal values but I want
> them to be equal. Is there another way of doing this other than writing
> a before insert trigger?

I think you will need an after trigger to enforce that.
You might also consider using some other value than NULL. If other tables
are going to reference this one using the unique column, potentially having
a NULL could be a problem.

pgsql-general by date:

Previous
From: John Cunningham
Date:
Subject: pgpool
Next
From: Michael Fuhr
Date:
Subject: Re: vacuum vs open transactions