Re: partial unique constraint

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Treat <xzilla@users.sourceforge.net>
Cc: pgsql-sql@postgresql.org
Date: 2004-04-06T15:17:03Z
Lists: 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