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就比较重要了。

    结束

  • 相关阅读:
    蓝桥杯 阶乘 取模
    蓝桥杯 字串统计 字符串操作
    蓝桥杯 字符删除 字符串操作
    蓝桥杯 新生舞会 map
    蓝桥杯 黑色星期五 基姆拉尔森公式
    蓝桥杯 最大体积 数论 dp
    蓝桥杯 貌似化学 数学问题
    tkinter文本显示用户输入 分类: python 小练习 python 2013-06-30 17:17 440人阅读 评论(0) 收藏
    tkinter计算字符串的值 分类: python 小练习 python 2013-06-30 17:11 299人阅读 评论(0) 收藏
    tkinter显示当前时间 分类: python 2013-06-30 17:08 402人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/zl520/p/9946309.html
Copyright © 2011-2022 走看看