Case insensitive uniqueness on column?

Lists: pgsql-general
From: doug <douglaskorchinski(at)nospam(dot)shaw(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Case insensitive uniqueness on column?
Date: 2003-05-19 01:36:09
Message-ID: dyWxa.23250$Vi5.677711@news1.calgary.shaw.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Can this be done in postgres?


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: doug <douglaskorchinski(at)nospam(dot)shaw(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Case insensitive uniqueness on column?
Date: 2003-05-25 02:05:29
Message-ID: 200305250205.h4P25Tk22950@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

doug wrote:
> Can this be done in postgres?

You mean:

Case insensitive uniqueness on column?

Yes. You have to create a functional index on the column using
lower(col), like:

CREATE UNIQUE INDEX uq on tab (lower(col))

I think that will work.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073