Re: How does PostgreSQL treat null values in unique composite

From: Michael Brusser <michael(at)synchronicity(dot)com>
To: P G <pg_dba(at)yahoo(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: How does PostgreSQL treat null values in unique composite
Date: 2003-04-08 18:23:35
Message-ID: DEEIJKLFNJGBEMBLBAHCIEHFDAAA.michael@synchronicity.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I suppose null is 'absence of value' rather than any
value (like an empty string) that can be compared with any
other value for uniqueness.
Mike.

> -----Original Message-----
> From: pgsql-admin-owner(at)postgresql(dot)org
> [mailto:pgsql-admin-owner(at)postgresql(dot)org]On Behalf Of P G
> Sent: Tuesday, April 08, 2003 2:14 PM
> To: pgsql-admin(at)postgresql(dot)org
> Subject: [ADMIN] How does PostgreSQL treat null values in unique
> composite constraints???
>
>
> I have the following table with a unique constraint.
>
> create table testt (
> id int,
> aa int,
> bb int,
> constraint pk_testt primary key (id),
> constraint cons_testt unique (aa,bb));
>
> Let's say I insert the following:
>
> insert into testt values (1,2,null);
> insert into testt values (2,2,null);
>
> I thought this should fail because of the unique
> constraint, but it doesn't. How does PostgreSQL view
> the null values in this constraint? Will someone
> explain why I am allowed to make this insertion?
>
> TIA.
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more
> http://tax.yahoo.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2003-04-08 19:10:35 Re: pg_class.reltuples not reset by VACUUM?
Previous Message Stephan Szabo 2003-04-08 18:18:41 Re: How does PostgreSQL treat null values in unique composite