Oracle 10g Time Zone Confusion

后端 未结 3 521
后悔当初
后悔当初 2020-12-30 16:38
SELECT TO_CHAR(SYSDATE, \'YYYY-MM-DD HH24:MI\')
      ,TO_CHAR(CURRENT_DATE, \'YYYY-MM-DD HH24:MI\')
      ,TO_CHAR(SYSTIMESTAMP, \'YYYY-MM-DD HH24:MI TZR\') 
               


        
3条回答
  •  渐次进展
    2020-12-30 16:47

    There are actually 3 timezones here, not 2

    • the timezone of the session/client
      • Shown in SESSIONTIMEZONE
      • This is the timezone of CURRENT_DATE, LOCALTIMESTAMP and CURRENT_TIMESTAMP. The difference between those 3 is the return type, they return a DATE, TIMESTAMP, and TIMESTAMP WITH TIME ZONE respectively)
    • The database timezone
      • Shown in DBTIMEZONE
      • This is the the timezone used for the internal storage of TIMESTAMP WITH LOCAL TIME ZONE values. Note that values are converted to/from session timezone on insert/select so it actually isn't as important as it seems
      • This is NOT the timezone of SYSDATE/SYSTIMESTAMP
    • The database OS timezone
      • In unix, it is based on the TZ variable when Oracle is started
      • This is the timezone of SYSDATE and SYSTIMESTAMP

    In your first example, I can see that the session TZ is UTC-6, the database TZ is UTC, and the database OS timezone is UTC-6.

    In your second example, I can see that the session TZ is UTC-6, the database TZ is UTC+2, and the database OS timezone is UTC+1.

提交回复
热议问题