X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BCB284758E6 for ; Tue, 8 Apr 2003 14:18:42 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B859F474E42 for ; Tue, 8 Apr 2003 14:18:41 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D7439D600; Tue, 8 Apr 2003 11:18:41 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id CCF405C0A; Tue, 8 Apr 2003 11:18:41 -0700 (PDT) Date: Tue, 8 Apr 2003 11:18:41 -0700 (PDT) From: Stephan Szabo To: P G Cc: Subject: Re: How does PostgreSQL treat null values in unique composite In-Reply-To: <20030408181332.49933.qmail@web13310.mail.yahoo.com> Message-ID: <20030408111533.L52961-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-16.1 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/105 X-Sequence-Number: 8260 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.