Re: B-tree + sorting + unique constraint - Mailing list pgsql-general

From Jeff Davis
Subject Re: B-tree + sorting + unique constraint
Date
Msg-id 1293671054.13159.3.camel@jdavis-ux.asterdata.local
Whole thread Raw
In response to B-tree + sorting + unique constraint  (bricklen <bricklen@gmail.com>)
Responses Re: B-tree + sorting + unique constraint  (bricklen <bricklen@gmail.com>)
List pgsql-general
On Wed, 2010-12-29 at 16:39 -0800, bricklen wrote:
> -- works:
> create unique index t_uidx on t (x desc nulls last,y desc nulls last, z asc);
> drop index t_uidx;

...

> -- creating the unique constraint with sorting fails:
> alter table t add constraint t_xyz_uc unique (x desc nulls last,y desc
> nulls last, z asc);
>
> ERROR:  syntax error at or near "desc"
> LINE 1: alter table t add constraint t_uidx unique (x desc nulls las...

A UNIQUE constraint in a table definition only allows simple column
references. To get more advanced, you need to use the CREATE UNIQUE
INDEX syntax you showed above.

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: bricklen
Date:
Subject: B-tree + sorting + unique constraint
Next
From: bricklen
Date:
Subject: Re: B-tree + sorting + unique constraint