X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 633279FB321 for ; Thu, 10 Aug 2006 18:58:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 86869-01 for ; Thu, 10 Aug 2006 18:58:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id E1E079FB316 for ; Thu, 10 Aug 2006 18:58:04 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Thu, 10 Aug 2006 21:57:58 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 10 Aug 2006 16:57:58 -0500 Subject: Re: how do I check for lower case From: Scott Marlowe To: Juliann Meyer Cc: pgsql-sql@postgresql.org In-Reply-To: <44DB97C5.9090307@noaa.gov> References: <44DB97C5.9090307@noaa.gov> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1155247078.20252.172.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 10 Aug 2006 16:57:58 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.091 tagged_above=0 required=5 tests=AWL, SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200608/75 X-Sequence-Number: 26033 On Thu, 2006-08-10 at 15:32, Juliann Meyer wrote: > I have a table with a column, lets call it identifier, that is defined > as varchar(8) that should never contain lower case letters. Its a large > table. Is there a way to query the table to see if any values in this > column are lower case and to get a list out? The user interface > application that users use prevents them from adding an entry in lower > case now, but didn't in earlier version. You can also use the same upper / lower functions to make sure no lower case stuff gets into the table at a later date: test=> create table aaa (a text check (upper(a)=a)); CREATE TABLE test=> insert into aaa (a) values ('ABC'); INSERT 2120799293 1 test=> insert into aaa (a) values ('ABC123'); INSERT 2120799294 1 test=> insert into aaa (a) values ('ABC12a3'); ERROR: new row for relation "aaa" violates check constraint "aaa_a" viola!