1SQL> select dbtimezone, sessiontimezone from dual; 2 3DBTIME 4------ 5SESSIONTIMEZONE 6--------------------------------------------------------------------------- 7+00:00 8-08:00 9 10 11SQL> 12 13 14 15SQL> create table timetest(tme date,tmestp timestamp(3), tmestp_tz timestamp(3) with time zone, tmpstp_tzl timestamp(3) with local time zone); 16 17Table created. 18 19SQL> 20 21 22 23SQL> insert into timetest values(sysdate,sysdate,sysdate,sysdate); 24row created. 25 26SQL> select * from timetest; 27 28TME 29--------- 30TMESTP 31--------------------------------------------------------------------------- 32TMESTP_TZ 33--------------------------------------------------------------------------- 34TMPSTP_TZL 35--------------------------------------------------------------------------- 3611-Nov-12 3711-NOV-12 11.56.27.000 PM 3811-NOV-12 11.56.27.000 PM -08:00 3911-NOV-12 11.56.27.000 PM
对比10
1SQL> select dbtimezone, sessiontimezone from dual; 2 3DBTIME 4------ 5SESSIONTIMEZONE 6--------------------------------------------------------------------------- 7+00:00 8-08:00 9 10 11SQL> 12 13 14 15SQL> create table timetest(tme date,tmestp timestamp(3), tmestp_tz timestamp(3) with time zone, tmpstp_tzl timestamp(3) with local time zone); 16 17Table created. 18 19SQL> 20 21 22 23SQL> insert into timetest values(sysdate,sysdate,sysdate,sysdate); 24row created. 25 26SQL> select * from timetest; 27 28TME 29--------- 30TMESTP 31--------------------------------------------------------------------------- 32TMESTP_TZ 33--------------------------------------------------------------------------- 34TMPSTP_TZL 35--------------------------------------------------------------------------- 3611-Nov-12 3711-NOV-12 11.56.27.000 PM 3811-NOV-12 11.56.27.000 PM -08:00 3911-NOV-12 11.56.27.000 PM
从此处可以看到:
timestamp with time zone 表达的是 针对 标准时区(格林尼治时间)的差。
timestamp with local time zone 表达的是 ,根据你当前所处时区,变化你和格林尼治时间的差。
如果过去相对标准时区 -8 ,那么移动到+10 时区的时候,需要加:10-(-8)=18 ,
就是 夜里11点56分+18小时 -->夜11点+1点+17小时+56分,-->凌晨过17小时+56分 -->凌晨+12小时+5小时+56分,
就是下午5小时56分。
那么,在跨越多时区的系统里,timestamp with timezone 或者 timestamp with local timezone就比较重要了。
结束