Re: int4 to varchar length (pgadmin3) issue

Поиск
Список
Период
Сортировка
От Andreas
Тема Re: int4 to varchar length (pgadmin3) issue
Дата
Msg-id 4503658F.4000605@gmx.net
обсуждение исходный текст
Ответ на int4 to varchar length (pgadmin3) issue  (<operationsengineer1@yahoo.com>)
Список 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 по дате отправления:

Предыдущее
От: Daniel Staal
Дата:
Сообщение: Re: no more problems with mailing list addresses
Следующее
От: Andreas
Дата:
Сообщение: Re: int4 to varchar length (pgadmin3) issue