问题描述
oracle DB是否能够返回时区区域,例如欧洲/伦敦,而不只是抵消?我想知道服务器所在的区域名称。
从DUAL中选择SYSTIMESTAMP参数;返回日期,时间和偏移量:
2020-08-17 18:11:03.219138 -05:00
从double中选择DBTIMEZONE;返回偏移量:
-05:00
解决方法
Oracle仅从OS获得时区偏移,因此无法说出OS中设置了什么Region,因为存在许多具有相同偏移(-05:00)的时区。
但是您可以从Oracle内部执行OS命令:Windows上的tzutil /g
或Linux上的timedatectl
(或只是读/etc/timezone
)以获取扩展信息。
更新:例如,您可以使用我的软件包xt_shell来运行具有超时和扩展STDERR的OS命令。
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