pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: P G <pg_dba@yahoo.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: How does PostgreSQL treat null values in unique composite
Date: Tue, 8 Apr 2003 11:18:41 -0700 (PDT)
Message-ID: <20030408111533.L52961-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <20030408181332.49933.qmail@web13310.mail.yahoo.com>


On Tue, 8 Apr 2003, P G wrote:

> 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?

Two NULL values still satisfy a unique constraint.  A unique constraint is
defined in terms of the unique predicate.



view thread (7+ messages)  latest in thread

Message-ID: <20030408111533.L52961-100000@megazone23.bigpanda.com>
Permalink:  ../20030408111533.L52961-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20030408111533.L52961-100000@megazone23.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, pg_dba@yahoo.com
  Subject: Re: How does PostgreSQL treat null values in unique composite
  In-Reply-To: <20030408111533.L52961-100000@megazone23.bigpanda.com>
  References: <20030408181332.49933.qmail@web13310.mail.yahoo.com> <20030408111533.L52961-100000@megazone23.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox