Re: Newbie question

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Vinay <vinay(at)mdp(dot)net>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Newbie question
Date: 2003-06-26 20:29:08
Message-ID: Pine.LNX.4.33.0306261427370.1551-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, 26 Jun 2003, Vinay wrote:

> I have a very simple question regarding creating columns in a table
>
> Can we create a column in a table in such a way that it will allow only certain length, nothing less or nothing more
>
> here is an example
>
>
> create table test(column1 char(2));
>
> will create table with column1 which will accept characters upto length two.
> I want the column to accept the column value which is absolutely length of two.

create table p (name text check (length(name)=2));

I'm not sure I can make it work for char(), it seems, since char is always
autopadded out to two characters before it gets to the check constraint.

It will work with text and varchar(2) types.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bruno Wolff III 2003-06-26 20:39:11 Re: Newbie question
Previous Message Vinay 2003-06-26 19:59:55 Newbie question