2016-04-29 188 views
0

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

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表不显示改变的时区?

回答

0

请参阅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 
+0

但使用查询“从双重选择DBTIMEZONE”当无法看到的变化。它始终显示00:00 – aashii

+0

如果重新启动,则不会显示。 – Mat