Re: Problem with a Pettern Matching Check
От | Michael Fuhr |
---|---|
Тема | Re: Problem with a Pettern Matching Check |
Дата | |
Msg-id | 20050815224208.GA51332@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Problem with a Pettern Matching Check (Sebastian Siewior <lavish@kamp-dsl.de>) |
Ответы |
Re: Problem with a Pettern Matching Check
|
Список | pgsql-sql |
On Tue, Aug 16, 2005 at 12:19:50AM +0200, Sebastian Siewior wrote: > > create table t ( > col CHAR (3) CONSTRAINT numonly_col CHECK ( col ~ '^\\d+$' ) > ); > > This check avoids non-numbers like '1a1' and allows '123'. For some > reason, I'm unable to find out why, it also avoids things like '1' and > '12'. Could someone please give me hint? :) The CHAR(3) specification causes the value to be space-padded, so '1' becomes '1 ' (the digit "one" followed by two spaces). See "Character Types" in the documentation: http://www.postgresql.org/docs/8.0/static/datatype-character.html Do you have a reason for using a character type instead of a numeric type like integer? -- Michael Fuhr
В списке pgsql-sql по дате отправления: