Multi-Column Constraints and Null Values

From: Phillip Tornroth <ptornroth(at)intellidot(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Multi-Column Constraints and Null Values
Date: 2006-04-27 21:06:14
Message-ID: 303D0B49-F8EC-491C-8865-B7B819120C13@intellidot.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a problem in a number of my tables. I'd like to add uniqueness
constraints across multiple columns, but some of the columns are
nullable. This gives me trouble since when I create a constraint on
columns A and B.. I'd like the constraint to be enforced such that
you couldn't insert values ("value for A", null) twice. I understand
why the constraints work this way, but I'm wondering if anyone knows
of a workaround.

Feel free to spare me any "don't use nullable columns" responses. I
of course am aware that is an option. It's just one I'm hoping to
avoid as this is a legacy database and it would be a mammoth effort
to accomplish.

Thank you in advance!

Phill

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ben K. 2006-04-28 03:58:26 Re: LinkedList
Previous Message Andreas Haumer 2006-04-27 18:09:19 Re: Porting application with rules and triggers from PG 7.4.x