Re: enforcing alphabetic/numeric content in "char" column - Mailing list pgsql-novice

From Rod Kreisler
Subject Re: enforcing alphabetic/numeric content in "char" column
Date
Msg-id JNEGKNDJGBKLBDGPOPFOCEDFDEAA.rod@23net.net
Whole thread Raw
In response to enforcing alphabetic/numeric content in "char" column  (Joel Rodrigues <borgempath@Phreaker.net>)
Responses Re: enforcing alphabetic/numeric content in "char" column  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice

> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Joel Rodrigues
> Sent: Thursday, November 07, 2002 9:07 AM
> To: pgsql-novice@postgresql.org
> Subject: [NOVICE] enforcing alphabetic/numeric content in "char" column
>
>
> Hello,
>
> The task is to allow data entries like "007", leading zeros
> included. I tried various numeric data types and they all trim
> it down to "7". Using char(3) works, but I want to put a CHECK
> on it to ensure no non-numeric data is entered. The following,
> and numerous variations on it, do not work:
>
> iso3dnum    char(3) CHECK (iso3dnum ~ '[0-9]')
>
> Any suggestions ?
>


Your regex should be '^[0-9]$' (the one you have will allow any string as
long as there is a numeric character in it somewhere).


pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Speed Performance Question
Next
From: Bruno Wolff III
Date:
Subject: Re: enforcing alphabetic/numeric content in "char" column