Oracle 数据库中的 sysdate 和 dbtimezone 不同

编程入门 行业动态 更新时间:2024-10-23 19:31:29
本文介绍了Oracle 数据库中的 sysdate 和 dbtimezone 不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

使用此查询: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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 09:59:53,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   Oracle   dbtimezone   sysdate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!