Re: [GENERAL] Fwd: help with uniq index (fwd) - Mailing list pgsql-general

From Vadim Mikheev
Subject Re: [GENERAL] Fwd: help with uniq index (fwd)
Date
Msg-id 35B791E3.AF429A52@krs.ru
Whole thread Raw
In response to Fwd: help with uniq index (fwd)  (Lorenzo Huerta <lorhuerta@yahoo.com>)
List pgsql-general
Lorenzo Huerta wrote:
>
> can you all help me with this:
>
> > is there a way to create a unique index on a field
> > (in ver 6.3.1) and also
> > have a single non-uniq value in that value, ie the NULL value?

Why do you ask? Why don't you try first?

vac=> create table t (x int);
CREATE
vac=> create unique index ti on t (x);
CREATE
vac=> insert into t values (1);
INSERT 18444 1
vac=> insert into t values (1);
ERROR:  Cannot insert a duplicate key into a unique index
vac=> insert into t values (null);
INSERT 18446 1
vac=> insert into t values (null);
INSERT 18447 1
vac=> insert into t values (null);
INSERT 18448 1

Vadim

pgsql-general by date:

Previous
From: Lorenzo Huerta
Date:
Subject: Fwd: help with uniq index (fwd)
Next
From: Roberto Joao Lopes Garcia
Date:
Subject: How about this LOGO?