Re: PRIMARY KEY on a *group* of columns imply that each

From: Sebastian Böck <sebastianboeck(at)freenet(dot)de>
To: Stephane Bortzmeyer <bortzmeyer(at)nic(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PRIMARY KEY on a *group* of columns imply that each
Date: 2005-04-27 15:04:07
Message-ID: 426FA9E7.4040706@freenet.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephane Bortzmeyer wrote:
> On Wed, Apr 27, 2005 at 04:50:23PM +0200,
> Sebastian Böck <sebastianboeck(at)freenet(dot)de> wrote
> a message of 48 lines which said:
>
>
>>CREATE UNIQUE INDEX na ON x (name, address) WHERE address IS NULL;
>
>
> No, because it prevents two tuples with the same value of "name".

Ahh, sorry! Ment something more like:

CREATE TABLE table x (
name TEXT NOT NULL,
address INET
);

CREATE UNIQUE INDEX na ON x (name, address);
CREATE UNIQUE INDEX n ON x (name) WHERE address IS NULL;

HTH

Sebastian

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Philip Hallstrom 2005-04-27 15:10:14 Reduce size of $PGDATA for "demo cdrom"?
Previous Message Stephane Bortzmeyer 2005-04-27 15:00:17 Re: PRIMARY KEY on a *group* of columns imply that each column is NOT