Обсуждение: ERROR: column "time" cannot be cast to type bigint

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

ERROR: column "time" cannot be cast to type bigint

От
Saurabh Agrawal
Дата:
Hi All,

I am trying to alter column from "timestamp without timezone" to
"bigint" but getting below error:

#ALTER TABLE test ALTER column time type bigint;
#ERROR:  column "time" cannot be cast to type bigint

Is there any other method for alter column to bigint.

Regards
Saurabh Agrawal

Re: ERROR: column "time" cannot be cast to type bigint

От
Thomas Kellerer
Дата:
Saurabh Agrawal, 20.04.2011 08:38:
> Hi All,
>
> I am trying to alter column from "timestamp without timezone" to
> "bigint" but getting below error:
>
> #ALTER TABLE test ALTER column time type bigint;
> #ERROR:  column "time" cannot be cast to type bigint
>
> Is there any other method for alter column to bigint.


This should do it:

ALTER TABLE test ALTER column time type bigint USING extract(epoch from time)

(Btw: I would avoid column names that are keywords like "time")

Thomas