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

From Andreas
Subject Re: int4 to varchar length (pgadmin3) issue
Date
Msg-id 4503658F.4000605@gmx.net
Whole thread Raw
In response to int4 to varchar length (pgadmin3) issue  (<operationsengineer1@yahoo.com>)
List pgsql-novice

operationsengineer1@yahoo.com schrieb:
> when i change (in pgadmin3) the int4 columns to
> varchar, everything goes well in pgadmin3 up until the
> grayed out box for the length of the varchar stays
> grayed out.
>
> 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.

You could add a new varchar(2) column with a temporary name like "tempname".
I suppose your revisionnumbers are stored in am column "revisioninfo"
and none of them has more than 2 digits and all are positive.

Then run :   update table1 set tempname = revisioninfo;
That copies the existing data into the new column and does an implicit
typecast from int4 to char.

Now you can drop your numeric column "revisioninfo" and rename the
column "tempname" to "revisioninfo".

Setting an explicit constraint to watch the varchar(2) column isn't
necesary this way because the PG won't let you insert more than 2 chars
anyway.

pgsql-novice by date:

Previous
From: Daniel Staal
Date:
Subject: Re: no more problems with mailing list addresses
Next
From: Andreas
Date:
Subject: Re: int4 to varchar length (pgadmin3) issue