From: | "Jim C(dot) Nasby" <jim(at)nasby(dot)net> |
---|---|
To: | Dennis Gearon <gearond(at)cvc(dot)net> |
Cc: | P G <pg_dba(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: How does PostgreSQL treat null values in unique composite |
Date: | 2003-04-09 00:31:29 |
Message-ID: | 20030408193129.T31861@flake.decibel.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)nasby(dot)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?"
From | Date | Subject | |
---|---|---|---|
Next Message | Brent Wood | 2003-04-09 00:44:48 | Re: Yet Another (Simple) Case of Index not used |
Previous Message | Denis @ Next2Me | 2003-04-09 00:21:16 | Re: [SQL] Yet Another (Simple) Case of Index not used |