From: | Andreas Wenk <a(dot)wenk(at)netzmeister-st-pauli(dot)de> |
---|---|
To: | Greg Stark <gsstark(at)mit(dot)edu> |
Cc: | Kevin Kempter <kevink(at)consistentstate(dot)com>, pgsql-admin(at)postgresql(dot)org |
Subject: | Re: force varchar column to be lowercase |
Date: | 2009-07-28 11:11:34 |
Message-ID: | 4A6EDCE6.5090102@netzmeister-st-pauli.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Greg Stark schrieb:
> On Tue, Jul 28, 2009 at 11:15 AM, Andreas
> Wenk<a(dot)wenk(at)netzmeister-st-pauli(dot)de> wrote:
>> Kevin Kempter schrieb:
>>> Can I use a check constraint, or something other than a function to force
>>> a column to be lowercase only?
>>>
>>>
>>> Thx in advance
>> try to use regexp in your CHECK CONSTRAINT:
>>
>> CHECK (column::bpchar ~ '^[a-z]+$'::bpchar::text)
>
> Better would be CHECK (column = tolower(column)) which won't fail on
> non-letters and will work in non-C locales
yes . but Kevin was asking for a way without a function. And by the way - it should read
lower instead of tolower ... or am I wrong?
Cheers
Andy
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Spiegelberg | 2009-07-28 12:05:07 | Re: WAL backup |
Previous Message | Greg Stark | 2009-07-28 10:50:28 | Re: force varchar column to be lowercase |