无法识别 Oracle 数据库的正确时区
Unable to identify the correct timezone of the Oracle database
我正在尝试获取我的 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 | Property_Value
---------------------------------------- -----
DBTIMEZONE .....-06:00
那为什么 Dual table 没有显示更改后的时区?
参见the docs(搜索set_time_zone_clause
):set time_zone
修改需要重启数据库后才能生效
After setting or changing the time zone with this clause, you must restart the database for the new time zone to take effect.
演示:
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
我正在尝试获取我的 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 | Property_Value
---------------------------------------- -----
DBTIMEZONE .....-06:00
那为什么 Dual table 没有显示更改后的时区?
参见the docs(搜索set_time_zone_clause
):set time_zone
修改需要重启数据库后才能生效
After setting or changing the time zone with this clause, you must restart the database for the new time zone to take effect.
演示:
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