Re: Use of !~* to keep a varchar column UNIQUE case-insensitive

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Don Morrison" <donmorrison(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Use of !~* to keep a varchar column UNIQUE case-insensitive
Date: 2006-08-18 16:48:03
Message-ID: 21447.1155919683@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Don Morrison" <donmorrison(at)gmail(dot)com> writes:
> Has anyone come up with a way, or ways to trim leading and trailing
> whitespace, then do a case-insensitive uniqueness check efficiently
> and semi-elegantly?

Use a unique functional index, eg this handles the case sensitivity
issue:

create unique index fooi on foo (lower(name));

Suppressing whitespace is left as an exercise for the reader...

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Don Morrison 2006-08-18 16:49:06 Re: Use of !~* to keep a varchar column UNIQUE case-insensitive
Previous Message Sean Davis 2006-08-18 16:44:53 Re: Use of !~* to keep a varchar column UNIQUE