Change timezone component of TIMESTAMP WITH TIMEZONE in Oracle

早过忘川 提交于 2019-12-19 19:54:40

问题


I have some data that is stored in a TIMESTAMP(6) WITH TIMEZONE column in Oracle, but it is stored in the wrong timezone. By convention, all timestamps in the DB must be stored in UTC, but this data was incorrectly persisted as EDT. The actual values are equivalent to the correct UTC value; the problem is simply that it is stored as 19-JUN-12 12.20.42.000000000 PM AMERICA/NEW_YORK when instead it should be 19-JUN-12 16.20.42.000000000 PM UTC. Is there any way in Oracle to change this?


回答1:


Do you really need to change the data that is stored in the database? Normally, it's sufficient just to convert to a different time zone for display, i.e.

SELECT <<your_timestamp_column>> AT TIME ZONE 'UTC'
  FROM <<your table>>

Of course, if you want to, you can also

UPDATE <<your table>>
   SET <<your timestamp column>> = <<your timestamp column>> AT TIME ZONE 'UTC'

to change all the data.



来源:https://stackoverflow.com/questions/11106703/change-timezone-component-of-timestamp-with-timezone-in-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!