Re: partial unique constraint - Mailing list pgsql-sql

From Tom Lane
Subject Re: partial unique constraint
Date
Msg-id 24888.1081264623@sss.pgh.pa.us
Whole thread Raw
In response to partial unique constraint  (Robert Treat <xzilla@users.sourceforge.net>)
Responses Re: partial unique constraint  (Robert Treat <xzilla@users.sourceforge.net>)
List pgsql-sql
Robert Treat <xzilla@users.sourceforge.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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: could not devise a query plan
Next
From: Achilleus Mantzios
Date:
Subject: Re: partial unique constraint