Re: int4 to varchar length (pgadmin3) issue

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
Cc: operationsengineer1(at)yahoo(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: int4 to varchar length (pgadmin3) issue
Date: 2006-09-10 01:39:05
Message-ID: 45036CB9.3040404@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Richard Broersma Jr schrieb:
>> iow, i want to limit the the newly converted varchar
>> revision to 2 characters, but can't due to the grayed
>> out boxes in pgadmin3.
>
> I saw this example at:
> http://www.postgresql.org/docs/8.1/interactive/sql-altertable.html
>
> ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);
>
> This should do what you want.

Actually it is not.
This constraint enforces the length of zipcodes to exactly 5 chars.

operationsengineer1 rather wants an upper limit of 2 chars but not
exactly 2 everywhere.
Theres no need for a separate constraint as a comumn declaration of
varchar(2) would do.

operationsengineer1's problem is that pgAdmin lets him change the data
type of the column but not the size of the resulting varchar. The size
field in the form is inactive and empty.
Thats a wee bit silly of pgAdmin because it lets you alter the size of
varchar columns that are created as varchar in the first place but not
of columns that got converted to varchar.

But thanks to your link to the documentation I found the solution.

ALTER TABLE table1 ALTER COLUMN revisioninfo TYPE varchar(2);

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2006-09-10 02:36:56 Re: Progress and Questions
Previous Message Andreas 2006-09-10 01:08:31 Re: int4 to varchar length (pgadmin3) issue