Re: Case insensitive unique constraint

From: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
To: Rob Brenart <postgresql(at)oculardata(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Case insensitive unique constraint
Date: 2005-07-14 08:06:41
Message-ID: 42D61D1123B.BDB0KG@129.180.47.120
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 14 Jul 2005 02:14:16 -0500, Rob Brenart <postgresql(at)oculardata(dot)com> wrote:
> I have a simple table to store account names... I want each name to be
> unique in a case insensitive manner... but I want the case the user
> enters to be remembered so I can't do a simple lower() on the data's way in.
>
> Is there an easy way to go about this? Am I about to write my first
> server side function for postgresql?

how about
create unique index tbl_iname_idx on tbl (lower(name_field))

klint.

+---------------------------------------+-----------------+
: Klint Gore : "Non rhyming :
: EMail : kg(at)kgb(dot)une(dot)edu(dot)au : slang - the :
: Snail : A.B.R.I. : possibilities :
: Mail University of New England : are useless" :
: Armidale NSW 2351 Australia : L.J.J. :
: Fax : +61 2 6772 5376 : :
+---------------------------------------+-----------------+

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2005-07-14 08:08:41 Re: To Postgres or not
Previous Message Roman Neuhauser 2005-07-14 08:03:31 Re: Case insensitive unique constraint