【发布时间】:2020-12-07 11:40:42
【问题描述】:
oracle DB 是否能够返回时区区域,例如欧洲/伦敦而不仅仅是抵消?我想知道服务器所在的区域名称。
从 DUAL 中选择 SYSTIMESTAMP 参数;返回日期、时间和偏移量:
2020-08-17 18:11:03.219138 -05:00
从双重选择 DBTIMEZONE;返回偏移量:
-05:00
【问题讨论】:
标签: oracle timezone timezone-offset
oracle DB 是否能够返回时区区域,例如欧洲/伦敦而不仅仅是抵消?我想知道服务器所在的区域名称。
从 DUAL 中选择 SYSTIMESTAMP 参数;返回日期、时间和偏移量:
2020-08-17 18:11:03.219138 -05:00
从双重选择 DBTIMEZONE;返回偏移量:
-05:00
【问题讨论】:
标签: oracle timezone timezone-offset
Oracle 仅从操作系统获取时区偏移量,因此无法说明操作系统中设置了哪个区域,因为有很多时区区域具有相同的偏移量 (-05:00)。
但您可以在 Oracle 中执行操作系统命令:Windows 上的tzutil /g 或 Linux 上的timedatectl(或阅读/etc/timezone)以获取扩展信息。
更新:例如,您可以使用我的包 xt_shell 来运行带有超时和扩展 STDERR 的操作系统命令。
https://github.com/xtender/xt_shell
select * from table(xt_shell.shell_exec('/usr/bin/timedatectl',1000));
结果:
SQL> select * from table(xt_shell.shell_exec('/usr/bin/timedatectl',1000));
COLUMN_VALUE
---------------------------------------------------
Local time: Tue 2020-08-18 11:25:06 UTC
Universal time: Tue 2020-08-18 11:25:06 UTC
RTC time: Tue 2020-08-18 11:25:06
Time zone: Europe/Berlin (UTC, +0000)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
【讨论】: