Oracle current_date和sysdate時間不一致解決

來源:互聯網
上載者:User

Oracle current_date和sysdate時間不一致解決

前段時間,發現一套新裝載的Rac資料庫所在作業系統時間不對,查詢dbtimezone發現為-06:00,說明時區不對;
select dbtimezone from dual;
 
DBTIME
 
---------
 
-06:00
 
OK,先將rac停掉,再在一段啟動資料庫,更改time_zone參數:
 
alter database set time_zone='+08:00';

更改參數後,將資料庫shutdown,再將Rac資料庫啟動起來;

接著分別運行以下SQL,查看時間是否校準:
 
select sysdate from dual;
 
select current_date from dual;
 
select current_timestamp from dual;
 
host date
 
select systimestamp from dual;
 
在sqlplus中發現時間一致,但是開發反應使用pl/sql查詢的時候顯示時間不一致。即sysdate,systimestamp很current_date,current_timestamp的時間不一致。
 
都知道sysdate,systimestamp取的是系統的時間,為什麼sqlplus中查詢的值是準確的值,而通過pl/sql串連查詢的值就不是準確的?
 
為了定位是不是資料庫的問題,在該作業系統上使用DBCA重新建立一個test DB,之後查看該test資料庫,發現問題依舊,從此處可以大概估算下應該不是資料庫的問題,是作業系統的問題。
 
在AIX作業系統下date看到作業系統時區為BEIST-8,由於是測試庫,將作業系統時區改為CST(Asia/shanghai)之後,重啟作業系統,使用pl/sql串連資料庫,發現問題解決,所有時間均一致,且都在東八區。

--------------------------------------------------------------------------------

Linux-6-64下安裝Oracle 12C筆記

在CentOS 6.4下安裝Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虛擬機器中安裝步驟

Debian 下 安裝 Oracle 11g XE R2

--------------------------------------------------------------------------------

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.