Re: force varchar column to be lowercase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 28, 2009 at 11:15 AM, Andreas
Wenk<a.wenk@xxxxxxxxxxxxxxxxxxxxxxx> 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

-- 
greg
http://mit.edu/~gsstark/resume.pdf

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux