Re: How does PostgreSQL treat null values in unique composite - Mailing list pgsql-general

From Jim C. Nasby
Subject Re: How does PostgreSQL treat null values in unique composite
Date
Msg-id 20030408193129.T31861@flake.decibel.org
Whole thread Raw
In response to Re: How does PostgreSQL treat null values in unique composite  (Dennis Gearon <gearond@cvc.net>)
Responses Re: How does PostgreSQL treat null values in unique  (Neil Conway <neilc@samurai.com>)
List pgsql-general
On Tue, Apr 08, 2003 at 11:46:41AM -0700, Dennis Gearon wrote:
> the sql paradigm says NULL is 'unknown'
>
> So, you can have unique values in a column, but the unknown ones are ignored.
> this can be very handy, but is best used only in date/date related fields
> because NULLS complicate many SQL statements.

Take note that there is no standard for how NULLs are handled in unique
constraints, though. Some databases act like pgsql, some treat null as a
single unique value (what you were expecting), and some disallow unique
constraints on any columns that are nullable.

BTW, I think pgsql's ability to index on a function would enable you to
get the behavior you were expecting by indexing on something like
coalesce(aa,'null'), coalesce(bb,'null')
--
Jim C. Nasby (aka Decibel!)                    jim@nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


pgsql-general by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Indexes intersection
Next
From: Neil Conway
Date:
Subject: Re: How does PostgreSQL treat null values in unique