Re: feature request: create table with unique constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: wumpus(at)z1p(dot)biz
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: feature request: create table with unique constraint
Date: 2009-12-17 22:39:39
Message-ID: 24204.1261089579@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<wumpus(at)z1p(dot)biz> writes:
> , unique ( a_id , ( case when actual then 0 else id end ) )

> Why can i not define the unique constraint in the
> create table?

The syntax for a unique constraint in CREATE TABLE is defined by the SQL
standard, and it doesn't include expressions. More than the syntax, a
unique constraint also ought to show up in the information_schema views,
and those don't have the ability to handle expressions. So we have the
capability, but it's only available via CREATE INDEX which is outside
the standard.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-17 22:46:03 Re: alter table performance
Previous Message Adrian Klaver 2009-12-17 22:39:20 Re: pg_dump and ON DELETE CASCADE problem