Re: int4 to varchar length (pgadmin3) issue - Mailing list pgsql-novice

From Andreas
Subject Re: int4 to varchar length (pgadmin3) issue
Date
Msg-id 45036CB9.3040404@gmx.net
Whole thread Raw
In response to Re: int4 to varchar length (pgadmin3) issue  (Richard Broersma Jr <rabroersma@yahoo.com>)
List 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);


pgsql-novice by date:

Previous
From: Andreas
Date:
Subject: Re: int4 to varchar length (pgadmin3) issue
Next
From:
Date:
Subject: Re: Progress and Questions