Re: enforcing alphabetic/numeric content in "char" column
В списке pgsql-novice по дате отправления:
| От | Michael Paesold |
|---|---|
| Тема | Re: enforcing alphabetic/numeric content in "char" column |
| Дата | |
| Msg-id | 02ec01c28689$b3e75900$4201a8c0@beeblebrox обсуждение исходный текст |
| Ответ на | Re: enforcing alphabetic/numeric content in "char" column (Rod Kreisler <rod@23net.net>) |
| Список | pgsql-novice |
Rod Kreisler" <rod@23net.net> wrote:
> Joel Rodrigues wrote:
> > 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).
'^[0-9]$' only allows exactly one digit
'^[0-9]+$' allows one or more digis
'^[0-9]{3,3}$' means exactly 3 digits
Regards,
Michael Paesold
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера