Обсуждение: trying to alter column

Поиск
Список
Период
Сортировка

trying to alter column

От
Aras Angelo
Дата:
Im trying to alter a column type from character varying(8) to int.
All the values in the column are numbers but im getting this message

column "xxxxxx" cannot be cast to type integer

Dropping and readding the column is an option but downtime is very critical to us, so i was wondering
if im doing something wrong and i can alter type somehow.
 

Re: trying to alter column

От
Scott Marlowe
Дата:
On Wed, Aug 19, 2009 at 6:20 PM, Aras Angelo<araskoktas@gmail.com> wrote:
> Im trying to alter a column type from character varying(8) to int.
> All the values in the column are numbers but im getting this message
>
> column "xxxxxx" cannot be cast to type integer
>
> Dropping and readding the column is an option but downtime is very critical
> to us, so i was wondering
> if im doing something wrong and i can alter type somehow.

alter table xyz alter COLUMN i type int using i::int;

Note that this will fail if any of the entries in teh column i are not ints.