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

From: "Don Morrison" <donmorrison(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Use of !~* to keep a varchar column UNIQUE case-insensitive
Date: 2006-08-18 16:38:03
Message-ID: aee6519f0608180938t59a30860mfbf706b0ba2d7f84@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello All,

Is there a sane way to do this?

I have a table with a column: "name VARCHAR(40) NOT NULL UNIQUE"

Two problems with this:

1)UNIQUE is case-sensitive
2)UNIQUE is whitespace sensitive

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?

If not, I can live with it...just hoping. :)

Thanks,
Don

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-08-18 16:41:58 Re: Function error- A column definition list is required for functions returning "record"
Previous Message ben sewell 2006-08-18 15:15:20 Function error- A column definition list is required for functions returning "record"