From: Jim C. Nasby <jnasby@pervasive.com>
To: Diego <diego@unimedijui.com.br>
Cc: pgsql-admin@postgresql.org
Subject: Re: UNIQUE KEY with null value...
Date: Tue, 1 Nov 2005 11:43:12 -0600
Message-ID: <20051101174312.GT20349@pervasive.com> (raw)
In-Reply-To: <4367AF54.6010909@unimedijui.com.br>
References: <4367AF54.6010909@unimedijui.com.br>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jnasby@pervasive.com, diego@unimedijui.com.br
Subject: Re: UNIQUE KEY with null value...
In-Reply-To: <20051101174312.GT20349@pervasive.com>
References: <4367AF54.6010909@unimedijui.com.br> <20051101174312.GT20349@pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox