Re: How to create a case-insensitive unique constraint? - Mailing list pgsql-general

From Tom Lane
Subject Re: How to create a case-insensitive unique constraint?
Date
Msg-id 6404.1220391052@sss.pgh.pa.us
Whole thread Raw
In response to How to create a case-insensitive unique constraint?  ("Kynn Jones" <kynnjo@gmail.com>)
List pgsql-general
"Kynn Jones" <kynnjo@gmail.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

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: plpgsql returning resultset
Next
From: "Dennis Brakhane"
Date:
Subject: Re: How to create a case-insensitive unique constraint?