ALTER TABLE with USING clause for timestamp

From: Josh Trutwin <josh(at)trutwins(dot)homeip(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: ALTER TABLE with USING clause for timestamp
Date: 2008-03-20 16:02:21
Message-ID: 20080320110221.1e5661e4@sinkhole.intrcomm.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

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"

From reading the ALTER TABLE documents there appears to be a USING
clause that I could use to do the cast manually, but the examples are
for converting integers to timestamps and my google-fu isn't giving
me any help. Any ideas on how to convert from text to time without
a drop/add? The data is in HH:MM:SS format.

PG 8.1

Thanks,

Josh

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zubkovsky, Sergey 2008-03-20 16:13:04 Re: Row size overhead
Previous Message Ivan Sergio Borgonovo 2008-03-20 15:43:55 dynamically generated SQL and planner/performance