Re: ALTER TABLE with USING clause for timestamp - Mailing list pgsql-general

From Tom Lane
Subject Re: ALTER TABLE with USING clause for timestamp
Date
Msg-id 25282.1206233954@sss.pgh.pa.us
Whole thread Raw
In response to ALTER TABLE with USING clause for timestamp  (Josh Trutwin <josh@trutwins.homeip.net>)
List pgsql-general
Josh Trutwin <josh@trutwins.homeip.net> writes:
> I have a column in a table defined as type TEXT and I'd like to
> convert to a TIME type - I tried this:
> ALTER TABLE t1 ALTER COLUMN tcol TYPE TIME WITHOUT TIME ZONE;
> which throws:
> ERROR:  column "tcol" cannot be cast to type "pg_catalog.time"

You just need to cast it explicitly --- to prevent surprises, ALTER
COLUMN TYPE won't implicitly do anything there's no implicit cast for.

ALTER TABLE t1 ALTER COLUMN tcol TYPE TIME USING tcol::TIME;

            regards, tom lane

pgsql-general by date:

Previous
From: Robert Treat
Date:
Subject: Re: Postgres development
Next
From: "James B. Byrne"
Date:
Subject: Re: MySQL to Postgres question