Re: partial unique constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: partial unique constraint
Date: 2004-04-06 15:17:03
Message-ID: 24888.1081264623@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> writes:
> Trying to come up with the proper syntax to meet the following criteria:
> create table foo (bar integer, baz boolean UNIQUE (bar, baz = true));

The correct way to do it is with a separate CREATE INDEX command:

create table foo (bar integer, baz boolean);
create unique index fooi on foo (bar) where baz = true;

Personally I'd spell that last as just "where baz" ...

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2004-04-06 15:17:49 Re: partial unique constraint
Previous Message ries 2004-04-06 15:05:37 Re: partial unique constraint