TIMEZONE的时区组件

TIMEZONE的时区组件

本文介绍了在Oracle中更改TIMESTAMP WITH TIMEZONE的时区组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些数据存储在Oracle的 TIMESTAMP(6)WITH TIMEZONE 列中,但是存储在错误的时区中。按照惯例,数据库中的所有时间戳都必须存储在UTC中,但是此数据被错误地保存为EDT。实际值等于正确的UTC值;问题很简单,它存储为 12-JUN-12 12.20.42.000000000 PM AMERICA / NEW_YORK 而应该存储为 12-JUN-12 UTC 16.20.42.000000000 PM 。 Oracle中是否有任何方法来更改此设置?

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?

推荐答案

您是否真的需要更改数据存储在数据库中?通常,只需将其转换为其他时区即可显示,即

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'

更改所有数据。

这篇关于在Oracle中更改TIMESTAMP WITH TIMEZONE的时区组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:21