Re: How to create a case-insensitive unique constraint?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kynn Jones" <kynnjo(at)gmail(dot)com>
Cc: "pgsql-general General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to create a case-insensitive unique constraint?
Date: 2008-09-02 21:30:52
Message-ID: 6404.1220391052@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Kynn Jones" <kynnjo(at)gmail(dot)com> writes:
> ALTER TABLE foo
> ADD CONSTRAINT foo_unique_xy
> UNIQUE ( UPPER( x ), UPPER( y ) );

> ...I get a syntax error

This is disallowed by the SQL standard: UNIQUE constraints can only be
on plain columns. (The practical reason for following their rule is
that there'd be no way to represent more-general constraints in the
information_schema.)

Use the CREATE UNIQUE INDEX syntax instead.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message D. Dante Lorenso 2008-09-02 21:35:25 Re: Foreign Key normalization question
Previous Message Raymond O'Donnell 2008-09-02 21:29:37 Re: plpgsql returning resultset