【问题标题】:Unable to identify the correct timezone of the Oracle database无法识别 Oracle 数据库的正确时区
【发布时间】:2016-08-24 05:18:09
【问题描述】:

我正在尝试获取我的 Oracle 11g 数据库的时区。我运行以下查询:

select dbtimezone from dual;

DBTIMEZONE
-------
+00:00

然后我尝试了以下查询并检查了数据库的属性以查看时区:

select property_name, property_value from database_properties; 

Property_Name | PROPERTY_VALUE
---------------------------------------------- -----
DBTIMEZONE .... 00:00

现在我想更改数据库的时区。为此,我运行以下查询:

alter database set time_zone='-06:00';

数据库集 TIME_ZONE='-06:00' 已更改。

现在,当我尝试通过查询获取时区时:

select dbtimezone from dual;

DBTIMEZONE
-------------
+00:00

这里没有反映变化。

但是当我检查数据库属性中的时区时,我得到了更改的时区:

select property_name, property_value, description from database_properties;

Property_Name |属性值
---------------------------------------------- DBTIMEZONE .....-06:00

那么为什么 Dual 表没有显示更改的时区?

【问题讨论】:

    标签: sql oracle oracle11g oracle-sqldeveloper


    【解决方案1】:

    the docs(搜索set_time_zone_clause):set time_zone修改只有重启数据库后才会生效。

    使用该子句设置或更改时区后,必须重启数据库才能使新时区生效。

    演示:

    SQL> select dbtimezone from dual;
    
    DBTIME
    ------
    +00:00
    
    SQL> alter database set time_zone = '+01:00' ;
    
    Database altered.
    
    SQL> select dbtimezone from dual;
    
    DBTIME
    ------
    +00:00
    
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup
    ORACLE instance started.
    
    Total System Global Area 1610612736 bytes
    Fixed Size                  2924928 bytes
    Variable Size             754978432 bytes
    Database Buffers          838860800 bytes
    Redo Buffers               13848576 bytes
    Database mounted.
    Database opened.
    SQL> select dbtimezone from dual;
    
    DBTIME
    ------
    +01:00
    

    【讨论】:

    • 但是当使用查询'select dbtimezone from dual'时看不到变化。它总是显示 00:00
    • 重启就不行了。
    猜你喜欢
    • 2018-12-28
    • 2017-08-27
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多