zoukankan      html  css  js  c++  java
  • Oracle中的 timestamp 和 timestamp with time zone, timestamp with local time zone

    SQL> select dbtimezone, sessiontimezone from dual;                    
                        
    DBTIME                    
    ------                    
    SESSIONTIMEZONE                    
    ---------------------------------------------------------------------------                    
    +00:00                    
    -08:00                    
                        
                        
    SQL>                     
                        
                        
                        
    SQL> create table timetest(tme date,tmestp timestamp(3), tmestp_tz timestamp(3) with time zone, tmpstp_tzl timestamp(3) with local time zone);                    
                        
    Table created.                    
                        
    SQL>                     
                        
                        
                        
    SQL> insert into timetest values(sysdate,sysdate,sysdate,sysdate);                    
    row created.                    
                        
    SQL> select * from timetest;                    
                        
    TME                    
    ---------                    
    TMESTP                    
    ---------------------------------------------------------------------------                    
    TMESTP_TZ                    
    ---------------------------------------------------------------------------                    
    TMPSTP_TZL                    
    ---------------------------------------------------------------------------                    
    11-Nov-12                    
    11-NOV-12 11.56.27.000 PM                    
    11-NOV-12 11.56.27.000 PM -08:00                    
    11-NOV-12 11.56.27.000 PM
    

     对比10

    SQL> select dbtimezone, sessiontimezone from dual;                    
                        
    DBTIME                    
    ------                    
    SESSIONTIMEZONE                    
    ---------------------------------------------------------------------------                    
    +00:00                    
    -08:00                    
                        
                        
    SQL>                     
                        
                        
                        
    SQL> create table timetest(tme date,tmestp timestamp(3), tmestp_tz timestamp(3) with time zone, tmpstp_tzl timestamp(3) with local time zone);                    
                        
    Table created.                    
                        
    SQL>                     
                        
                        
                        
    SQL> insert into timetest values(sysdate,sysdate,sysdate,sysdate);                    
    row created.                    
                        
    SQL> select * from timetest;                    
                        
    TME                    
    ---------                    
    TMESTP                    
    ---------------------------------------------------------------------------                    
    TMESTP_TZ                    
    ---------------------------------------------------------------------------                    
    TMPSTP_TZL                    
    ---------------------------------------------------------------------------                    
    11-Nov-12                    
    11-NOV-12 11.56.27.000 PM                    
    11-NOV-12 11.56.27.000 PM -08:00                    
    11-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就比较重要了。

    结束

  • 相关阅读:
    opencv学习笔记(五)镜像对称
    opencv学习笔记(四)投影
    C++文件读写详解(ofstream,ifstream,fstream)
    C++ 提取字符串中的数字
    opencv学习笔记(三)基本数据类型
    opencv学习笔记(二)寻找轮廓
    分别心
    关于bonecp和QuerRunner
    关于AutoCommit
    一个detect问题引发的一系列思考
  • 原文地址:https://www.cnblogs.com/zl520/p/9946309.html
Copyright © 2011-2022 走看看