Re: Adding UNIQUE constraint on NULL column

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Dave Smith <dave(dot)smith(at)candata(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding UNIQUE constraint on NULL column
Date: 2005-01-13 17:16:58
Message-ID: 20050113171658.GB13594@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 13, 2005 at 09:01:08 -0500,
Dave Smith <dave(dot)smith(at)candata(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2005-01-13 17:33:50 Re: vacuum vs open transactions
Previous Message William Yu 2005-01-13 17:13:42 Re: pgsqlODBC problems