Thread: Add constraint for number of chars

Add constraint for number of chars

From
PostgreSQL Admin
Date:
Hi,

This is seemly simple, but I'm @ a loss this early in the morning.  It's
best explained this way

SAMPLE
-----------------------------------
id                  | serial            |
username   | varchar(100)| constraint username >=8 and username <=100

The problem is that it's characters not integers or numeric.  It my
constraint correct?

Thanks for the help,
J


Re: Add constraint for number of chars

From
Tom Lane
Date:
PostgreSQL Admin <postgres@productivitymedia.com> writes:
> username   | varchar(100)| constraint username >=8 and username <=100

Perhaps you mean "length(username) >= 8" and so on?
        regards, tom lane