0

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.

1
  • what is the requirement for altering column for particular rows? Commented Mar 11, 2015 at 7:30

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes , you're right. it works i used : UPDATE table set timestamp = timestamp AT TIME ZONE 'UTC' where timestamp < '2015-01-06 00:00:00'
2

you can't alter table column type using where, because "where" is DML and "alter" is DDL. Use update whe

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.