Skip site navigation (1) Skip section navigation (2)

Re: UNIQUE KEY with null value...

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Diego <diego(at)unimedijui(dot)com(dot)br>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: UNIQUE KEY with null value...
Date: 2005-11-01 17:43:12
Message-ID: 20051101174312.GT20349@pervasive.com (view raw or flat)
Thread:
Lists: pgsql-admin
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(at)pervasive(dot)com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

In response to

pgsql-admin by date

Next:From: DiegoDate: 2005-11-01 18:09:24
Subject: UNIQUE KEY with null value...
Previous:From: Jim C. NasbyDate: 2005-11-01 17:41:25
Subject: Re: Pre-allocate space in advance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group