Reputation: 63
I work with postgresql 9.3, I use this query to convert timestamp column to UTC.
ALTER TABLE table
ALTER timestamp TYPE timestamp
USING timestamp AT TIME ZONE 'UTC' ;
I need to add WHERE cluose to the query :
ALTER TABLE table
ALTER timestamp TYPE timestamp where timestamp < '2015-01-06 00:00:00'
USING timestamp AT TIME ZONE 'UTC' ;
but, this is didn't work . there no clear resource on how to do it.
Upvotes: 0
Views: 170
Reputation: 51446
you can't alter table column type using where, because "where" is DML and "alter" is DDL. Use update whe
Upvotes: 2
Reputation: 1252
You could apply ALTER TYPE construction only to whole column, not to some rows. If you want to convert timestamp value you should use UPDATE instead.
Upvotes: 2