時區和夏令時

DATE 資料型別不處理時區或夏令時變化。

或者:

DATE 可以儲存為協調世界時(UTC)並轉換為當前會話時區,如下所示:

SELECT FROM_TZ(
         CAST(
           TO_DATE( '2016-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS' )
           AS TIMESTAMP
         ),
         'UTC'
       )
       AT LOCAL AS time
FROM   DUAL;

如果你執行 ALTER SESSION SET TIME_ZONE = '+01:00';,那麼輸出是:

TIME2016-01-01 13:00:00.000000000 +01:00

ALTER SESSION SET TIME_ZONE = 'PST'; 然後輸出是:

TIME2016-01-01 04:00:00.000000000 PST