Re: How to create unique constraint on NULL columns

From: Dawid Kuroczko <qnex42(at)gmail(dot)com>
To: Andrus <eetasoft(at)online(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create unique constraint on NULL columns
Date: 2005-07-15 13:24:40
Message-ID: 758d5e7f05071506247317c18e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/15/05, Andrus <eetasoft(at)online(dot)ee> wrote:
> CREATE TABLE test( col1 CHAR NOT NULL, col2 CHAR,
> UNIQUE (col1, col2) );
> INSERT INTO test VALUES ( '1', NULL );
> INSERT INTO test VALUES ( '1', NULL );
> does NOT cause error!
>
> How to create constraint so that NULL values are treated equal and second
> insert is rejected ?

Please read:
http://www.postgresql.org/docs/8.0/interactive/indexes-unique.html
...or this list archives.

In short: NULL is not equal to NULL. NULL is a state, not a value.

Regards,
Dawid

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ketan shah 2005-07-15 13:49:17 how to insert '\\' in postgres database using java
Previous Message Andrus 2005-07-15 12:03:46 uncompressing pgAdmin backup file in windows