Re: int4 to varchar length (pgadmin3) issue

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: operationsengineer1(at)yahoo(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: int4 to varchar length (pgadmin3) issue
Date: 2006-09-10 01:08:31
Message-ID: 4503658F.4000605@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

operationsengineer1(at)yahoo(dot)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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas 2006-09-10 01:39:05 Re: int4 to varchar length (pgadmin3) issue
Previous Message Daniel Staal 2006-09-09 21:39:50 Re: no more problems with mailing list addresses