X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0CDCC476262 for ; Tue, 8 Apr 2003 14:20:46 -0400 (EDT) Received: from mailgw1.syncinc.com (unknown [63.126.54.34]) by postgresql.org (Postfix) with ESMTP id EE4DD476182 for ; Tue, 8 Apr 2003 14:20:44 -0400 (EDT) Received: from ascwf14yqi3m2t (h000795bff979.ne.client2.attbi.com [24.62.106.235]) by mailgw1.syncinc.com (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTPA id <0HD100F21EXH8R@mailgw1.syncinc.com> for pgsql-admin@postgresql.org; Tue, 08 Apr 2003 14:20:06 -0400 (EDT) Date: Tue, 08 Apr 2003 14:23:35 -0400 From: Michael Brusser Subject: Re: How does PostgreSQL treat null values in unique composite In-reply-to: <20030408181332.49933.qmail@web13310.mail.yahoo.com> To: P G , pgsql-admin@postgresql.org Reply-To: michael@synchronicity.com Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Spam-Status: No, hits=-17.9 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE,QUOTED_EMAIL_TEXT 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/106 X-Sequence-Number: 8261 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@postgresql.org > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of P G > Sent: Tuesday, April 08, 2003 2:14 PM > To: pgsql-admin@postgresql.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@postgresql.org) >