Oracle 更改 dbtimezone

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18869188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:55:37  来源:igfitidea点击:

Oracle change dbtimezone

oracleoracle11gtimezone

提问by Rémi

My database was configured with an dbtimezone=+2:00:

我的数据库配置了一个dbtimezone=+2:00

When my application sends a date which has a timezone, does Oracle automatically translate the date to its dbtimezoneand store it in the column?

当我的应用程序发送一个带有时区的日期时,Oracle 是否会自动将日期转换为其dbtimezone并将其存储在列中?

When my application asks for a field date, does Oracle automatically translate it to the application timezone?

当我的应用程序要求输入字段日期时,Oracle 是否会自动将其转换为应用程序时区?

In order to be consistency with business rules, I wanted to change this dbtimezoneto UTC. So I made the alter database set time_zone='UTC'command, I restarted the oracle server and now the select dbtimezone from dual;command returns "UTC".

为了与业务规则保持一致,我想将其更改dbtimezone为 UTC。所以我做了这个alter database set time_zone='UTC'命令,我重新启动了 oracle 服务器,现在select dbtimezone from dual;命令返回“UTC”。

But, all fields date in DB haven't changed (no change -2 hours from GMT+2 to UTC). When I ask the sysdate, it returns the GMT+2 date ... I try to change my SQL Developer configuration timezone to UTC but it didn't change anything. Do I have an issue of Oracle session parameters that convert my DB data to GMT+2 before displaying it ?

但是,DB 中的所有字段日期都没有改变(从 GMT+2 到 UTC 时间没有变化 -2 小时)。当我询问 sysdate 时,它​​返回 GMT+2 日期......我尝试将我的 SQL Developer 配置时区更改为 UTC,但它没有改变任何内容。在显示之前将我的数据库数据转换为 GMT+2 的 Oracle 会话参数是否存在问题?

Finally, does anyone have a good practice to make this change ? (change the database timezone and existing date to a new timezone).

最后,有没有人有好的做法来进行这种更改?(将数据库时区和现有日期更改为新时区)。

采纳答案by Matt Johnson-Pint

If all you're doing is changing the database time zone setting, then you are only going to notice any change in output if your data is stored with the TIMESTAMP WITH LOCAL TIME ZONEtype.

如果您所做的只是更改数据库时区设置,那么如果您的数据以该TIMESTAMP WITH LOCAL TIME ZONE类型存储,那么您只会注意到输出中的任何更改。

I don't recommend that though. It would be much better if your data was just stored in a regular TIMESTAMPfield and was already set to UTC.

不过我不建议这样做。如果您的数据只是存储在常规TIMESTAMP字段中并且已经设置为 UTC ,那就更好了。

You should read the documentation about all of the different date and time datatypes, so you understand how each of these types works and differs from the other.

您应该阅读有关所有不同日期和时间数据类型的文档,以便了解这些类型中的每一种是如何工作的以及彼此之间的区别。