Oracle 数据库中的 sysdate 和 dbtimezone 不同 [英] sysdate and dbtimezone different in Oracle Database

查看:40
本文介绍了Oracle 数据库中的 sysdate 和 dbtimezone 不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此查询:select sysdate from dual;

结果是:27-09-2018 07:50:50 -- 这个UK时间

the result is: 27-09-2018 07:50:50 -- this UK time

with : 从dual中选择dbtimezone;

输出:+10:00

我希望 sysdatedbtimezone

我试图用 alter database set time_zone='AEST' 来实现,但我有点困惑这是否是正确的解决方案.

I was trying to do it with alter database set time_zone='AEST', but i'm bit confused if this is the right solution.

最感谢任何帮助.谢谢.

Any help most appreciated. Thanks.

推荐答案

DBTIMEZONESYSDATESYSTIMESTAMP<的时区,这是一个常见的误解/代码>

It is a common misunderstanding that DBTIMEZONE is the time zone for SYSDATE and SYSTIMESTAMP

SYSDATESYSTIMESTAMP 以数据库服务器所在操作系统的时区返回.

SYSDATE and SYSTIMESTAMP are returned in time zone of the operating system on which the database server resides.

DBTIMEZONETIMESTAMP WITH LOCAL TIME 值的(内部)时区.我不知道它有什么实际用途.请注意,如果数据库包含具有 TIMESTAMP WITH LOCAL TIME ZONE 列的表并且该列包含数据,则不能更改数据库上的 DBTIMEZONE.

DBTIMEZONE is the (internal) time zone of TIMESTAMP WITH LOCAL TIME values. I don't know any practical use of it. Note, you cannot change DBTIMEZONE on your database if the database contains a table with a TIMESTAMP WITH LOCAL TIME ZONE column and the column contains data.

如果你想在 DBTIMEZONE 运行当前时间

If you want current time at DBTIMEZONE run

select SYSTIMESTAMP AT TIME ZONE DBTIMEZONE 
from dual;

CURRENT_TIMESTAMP AT TIME ZONE DBTIMEZONE 也有效.

另见如何处理日光保存在 Oracle 数据库中

这篇关于Oracle 数据库中的 sysdate 和 dbtimezone 不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆