【问题标题】:What is the use of SESSIONTIMEZONE and DBTIMEZONE in oracleoracle中的SESSIONTIMEZONE和DBTIMEZONE有什么用
【发布时间】:2020-05-12 09:01:18
【问题描述】:

除了获取会话时区偏移量和数据库时区偏移量之外,SESSIONTIMEZONEDBTIMEZONE 在 oracle 数据库中是否还有其他用途/作用。

我想知道的是,更改 SESSIONTIMEZONEDBTIMEZONE 值在向/从数据库中插入/检索日期方面有何影响。

【问题讨论】:

  • 您是否已经看过文档 - 例如herehere?

标签: oracle11g timezone


【解决方案1】:

这些函数中使用了会话和数据库时区。
- systimestamp dbtimezone 中的时间戳。
- current_timestamp sessiontimezone 中的时间戳。

而且可能在许多其他地方。我确信更改会影响 dbms_scheduler。
在从没有时区的日期时间到 timestamp with time zone 的隐式转换期间,Oracle 也在使用会话时区。

declare
 with_dbtimezone    TIMESTAMP WITH TIME ZONE := systimestamp; --dbtimezone 
 with_sesione_timezone  TIMESTAMP WITH TIME ZONE := current_timestamp; --sesione_timezone
 no_time_zone  TIMESTAMP := with_dbtimezone; -- remmove timezone from ;
 implicitit_converiosn  TIMESTAMP WITH TIME ZONE := no_time_zone;
begin 
 dbms_output.put_line(to_char(with_dbtimezone,'YYYY-MM-DD hh24:mi:ss TZR')); 
 dbms_output.put_line(to_char(with_sesione_timezone,'YYYY-MM-DD hh24:mi:ss TZR'));
 dbms_output.put_line(to_char(no_time_zone,'YYYY-MM-DD hh24:mi:ss TZR'));
 dbms_output.put_line(to_char(implicitit_converiosn,'YYYY-MM-DD hh24:mi:ss TZR'));
end;

【讨论】:

【解决方案2】:

sysdate and dbtimezone different in Oracle Database 解释了 dbtimezone、system timezone 和 sessiontimezone 之间的区别。

如果需要,这里是如何将 sessiontimezone 同步到系统时区:

begin execute immediate 'alter session set time_zone = ''' || to_char(systimestamp, 'TZR') || ''''; end;

【讨论】:

    猜你喜欢
    • 2013-08-07
    • 1970-01-01
    • 2019-03-03
    • 2014-10-20
    • 2020-05-20
    • 2023-02-03
    • 2012-05-25
    • 2020-09-17
    相关资源
    最近更新 更多