| From: | bricklen <bricklen(at)gmail(dot)com> |
|---|---|
| To: | Jeff Davis <pgsql(at)j-davis(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: B-tree + sorting + unique constraint |
| Date: | 2010-12-30 01:28:11 |
| Message-ID: | AANLkTim3=CRnpkX-nnSkM4W7JRgZimJoaxUN6vBT_vXk@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Wed, Dec 29, 2010 at 5:04 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> 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
Ok, thanks for your reply. I think I'll have to reread the docs to get
a better feel for those little nuances.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2010-12-30 02:12:36 | Re: what's the message: CONTEXT: PL/pgSQL function "proc_sub_b" line 7 at assignment |
| Previous Message | Jeff Davis | 2010-12-30 01:04:14 | Re: B-tree + sorting + unique constraint |