Re: Create Table Unique problem... bug?

From: Dani Oderbolz <oderbolz(at)ecologic(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Create Table Unique problem... bug?
Date: 2003-05-28 14:29:45
Message-ID: 3ED4C7D9.80002@ecologic.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Mauro Bertoli wrote:

>Hi, I've a problem creating a table. My Sql
>instruction is:
>
>CREATE TABLE questiontypes (
> id integer NOT NULL,
> flags integer,
> label text,
> UNIQUE (id,flags)
>);
>
>Is it ok?? I must have 'flags' like to NULL... but
>'id' is NOT NULL...
>Now if I insert a row:
>
>INSERT INTO questiontypes (id,flags,label) values
>(2,null,'a');
>
>and re-insert it... I can!!!! Now there are two
>identical row, and UNIQUE??
>I think postgres must occur an error? Is it Ok?
>
Hi Mauro,
yes, this is ok,
because NULL is not equal to NULL.
(In other words, every NULL is a Unique NULL).
Every comparison to NULL returns NULL.

Regards,
Dani

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Crombleholme, Roy 2003-05-28 14:34:58 Getting stats out of postgresql
Previous Message papapep 2003-05-28 13:51:15 Re: Inserting data of two other tables [Now deleting ...]