X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F1E6447633A for ; Tue, 8 Apr 2003 15:48:57 -0400 (EDT) Received: from web13306.mail.yahoo.com (web13306.mail.yahoo.com [216.136.175.42]) by postgresql.org (Postfix) with SMTP id F10D9476302 for ; Tue, 8 Apr 2003 15:48:56 -0400 (EDT) Message-ID: <20030408194858.77038.qmail@web13306.mail.yahoo.com> Received: from [67.95.85.164] by web13306.mail.yahoo.com via HTTP; Tue, 08 Apr 2003 12:48:57 PDT Date: Tue, 8 Apr 2003 12:48:57 -0700 (PDT) From: P G Subject: Re: How does PostgreSQL treat null values in unique composite To: pgsql-admin@postgresql.org In-Reply-To: <20030408193756.84413.qmail@web13309.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-16.3 required=5.0 tests=BAYES_01,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/117 X-Sequence-Number: 8272 Also, the "unique predicate" only explains what it means to be unique, but it says nothing about how null values are treated. Will someone explain what the value of null is? TIA. --- P G wrote: > Where can I find the documentation cited for the > "unique predicate" mentioned below? > > TIA. > > --- Stephan Szabo > wrote: > > > > 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. > > > > From the unique predicate: > > "If there are no two rows T such that the value of > > each column in one row > > is non-null and is equal to the value of the > > corresponding column in the > > other row according to Subclause 8.2, " > predicate>", then the > > result of the is true; > otherwise > > the result of the > > is false". > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the > > unregister command > > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online, calculators, forms, > and more > http://tax.yahoo.com > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com