Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UpZwo-0002EG-80 for pgsql-admin@arkaria.postgresql.org; Thu, 20 Jun 2013 08:10:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UpZwn-0006do-OY for pgsql-admin@arkaria.postgresql.org; Thu, 20 Jun 2013 08:10:25 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UpZwm-0006dh-Gc for pgsql-admin@postgresql.org; Thu, 20 Jun 2013 08:10:24 +0000 Received: from mail.sihirhosting.com ([77.92.143.143]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UpZwh-0003qV-QQ for pgsql-admin@postgresql.org; Thu, 20 Jun 2013 08:10:23 +0000 Received: (qmail 17739 invoked by uid 509); 20 Jun 2013 11:10:15 +0300 Received: from 89.145.186.242 by gaya (envelope-from , uid 507) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.7/2391. spamassassin: 3.0.2. perlscan: 1.25-st-qms. Clear:RC:0(89.145.186.242):SA:0(-97.4/6.7):. Processed in 2.979294 secs); 20 Jun 2013 08:10:15 -0000 X-Spam-Status: No, hits=-97.4 required=6.7 X-Antivirus-MYDOMAIN-Mail-From: emre.hasegeli@tart.com.tr via gaya X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(89.145.186.242):SA:0(-97.4/6.7):. Processed in 2.979294 secs Process 17723) Received: from unknown (HELO hasegeli.local) (emre.hasegeli@tart.com.tr@89.145.186.242) by mail.sihirhosting.com with AES256-SHA encrypted SMTP; 20 Jun 2013 11:10:12 +0300 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: pgsql-admin@postgresql.org, "Technical Doubts" Subject: Re: Composite Unique Key - Doubt References: Date: Thu, 20 Jun 2013 11:10:11 +0300 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Emre Hasegeli" Organization: =?utf-8?B?VGFydCDEsG50ZXJuZXQgVGVrbm9sb2ppbGVyaSBUaWNhcmV0IEHFng==?= Message-ID: In-Reply-To: User-Agent: Opera Mail/12.15 (MacIntel) X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org On Thu, 20 Jun 2013 10:42:37 +0300, Technical Doubts wrote: > Team, > > Am using Postgres 9.2 > > I am having a table > > technologies > ( > technologyid bigint, > status character(1), > implementeddate date > *CONSTRAINT technologies_uq UNIQUE (technologyid, status, > implementeddate)* > ) > > entering data as > > insert into technologies (technologyid,status,implementeddate) > values > (123,'P',null), > (123,'P',null); > > 2 rows affected. > > table accepting duplicate values in spite of composite unique > constraint.. > where I am doing wrong? You are not doing anything wrong. From documentation: > In general, a unique constraint is violated when there is more than one > row in the table where the values of all of the columns > included in > the constraint are equal. However, two null values are not considered > equal in this comparison. That means even in the presence of a unique > constraint it is possible to store duplicate rows that contain a null > value in at least one of the constrained columns. This behavior conforms > to the SQL standard, but we have heard that other SQL databases might > not follow this rule. So be careful when developing applications that > are intended to be portable. Try not null constraints or functional unique indexes. -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin