X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 33E0931008A for ; Thu, 26 Jun 2003 20:35:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 15438-07 for ; Thu, 26 Jun 2003 17:35:43 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 41DBA310085 for ; Thu, 26 Jun 2003 17:35:43 -0300 (ADT) Received: (qmail 10504 invoked by uid 500); 26 Jun 2003 20:39:11 -0000 Date: Thu, 26 Jun 2003 15:39:11 -0500 From: Bruno Wolff III To: Vinay Cc: pgsql-admin@postgresql.org Subject: Re: Newbie question Message-ID: <20030626203911.GA10461@wolff.to> Mail-Followup-To: Vinay , pgsql-admin@postgresql.org References: <001c01c33c1d$843e0100$157a40c0@vinay> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001c01c33c1d$843e0100$157a40c0@vinay> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/301 X-Sequence-Number: 9292 On Thu, Jun 26, 2003 at 15:59:55 -0400, 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. A char(2) will always have two characters (unless it is NULL). If you want to check for two nonblank characters or two letters or something like that use a check constraint. Some like: create table test ( col1 char(2) constraint bad_length check (col1 ~ '^[a-zA-Z][a-zA-Z]$' );