X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 590C6DB6B6 for ; Tue, 1 Nov 2005 13:43:14 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08519-02 for ; Tue, 1 Nov 2005 17:43:12 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8873DDB6E8 for ; Tue, 1 Nov 2005 13:43:12 -0400 (AST) Received: by flake.decibel.org (Postfix, from userid 1001) id 780721525A; Tue, 1 Nov 2005 11:43:12 -0600 (CST) Date: Tue, 1 Nov 2005 11:43:12 -0600 From: "Jim C. Nasby" To: Diego Cc: pgsql-admin@postgresql.org Subject: Re: UNIQUE KEY with null value... Message-ID: <20051101174312.GT20349@pervasive.com> References: <4367AF54.6010909@unimedijui.com.br> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4367AF54.6010909@unimedijui.com.br> X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.008 required=5 tests=[AWL=0.008] X-Spam-Score: 0.008 X-Spam-Level: X-Archive-Number: 200511/9 X-Sequence-Number: 19382 http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html For the purpose of a unique constraint, null values are not considered equal. On Tue, Nov 01, 2005 at 03:09:24PM -0300, Diego wrote: > Hi, > I?m a brazilian programmer! > > I have a question about Postgres UNIQUE KEY. Look: > > (Step 1) > CREATE TABLE test ( > id integer not null primary key, > id_uni integer not null, > cod integer, > name varchar(40), > constraint test_uk unique(id_uni, cod) > ) > > (Step 2) > insert into test (id, id_uni, cod, name) > values (1, 1, null, 'A') > > (Step 3) > insert into test (id, id_uni, cod, name) > values (2, 1, null, 'B') =========> [Have the same UNIQUE KEY] > > Why postgresql don?t break insertion in this case???? > > Thanks > Diego Ziquinatti > Brazil > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org > -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461