Skip site navigation (1) Skip section navigation (2)

Re: partial unique constraint

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: partial unique constraint
Date: 2004-04-06 16:38:41
Message-ID: 1081269521.31791.73.camel@camel (view raw or flat)
Thread:
Lists: pgsql-sql
On Tue, 2004-04-06 at 11:17, Tom Lane wrote:
> 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:

I think I had initially abandoned looking at that type of solution after
having run across this paragraph in the docs while looking for the
proper constraint syntax:

"Note:  The preferred way to add a unique constraint to a table is ALTER
TABLE ... ADD CONSTRAINT. The use of indexes to enforce unique
constraints could be considered an implementation detail that should not
be accessed directly."

The subliminal mind is a powerful force eh? Perhaps that paragraph
should be modified... but I'm not sure if it should expanded to include
thoughts along the lines of Stephan's response or maybe just drop the
"should not be accessed directly" bit...

Robert Treat
-- 
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL


In response to

Responses

pgsql-sql by date

Next:From: Bret HughesDate: 2004-04-06 16:51:36
Subject: Re: group by not returning sorted rows
Previous:From: Paul ThomasDate: 2004-04-06 15:26:02
Subject: Re: partial unique constraint

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group