[20170825]2038.txt

[20170825]2038.txt

–//昨天帮别人解决电脑问题联想到的,对方是主机电池没电,导致启动XP黑屏,重新设置正确的时间后ok.
–//这样我想到除了2000年外的2038年的问题,大家知道类unix的os系统计时从’1970/1/1’开始的秒数.
–//因为符号整形最大是2^31-1=2147483647秒.

SYS@book> select to_date(‘1970/1/1′,’yyyy-mm-dd’) + 2147483647/86400 from dual ;
TO_DATE(‘1970/1/1′,
——————-
2038-01-19 03:14:07

–//也就是到这个时间后涉及到许多设备也许手机,os,交换机等许多设备的系统时间也许都会被重置.
–//我记得OO曾经在海区发过类似的帖子,当时在我看来我那个时候已经退休…^_^.

–//顺便学习linux的data命令.

–//%s 显示秒数.
$ date +"%s %Y-%m-%d %T"
1503648237 2017-08-25 16:03:57

–//反过来如果知道秒数,如何显示时间能,google…

$ date -d "1970-01-01 00:00:00 UTC 1503648237 seconds" +"%Y-%m-%d %T"
2017-08-25 16:03:57

$ date -d "1970-01-01 00:00:00 UTC 2147483647 seconds" +"%Y-%m-%d %T"
2038-01-19 11:14:07
–//时区问题,相差8个小时.

$ date -d "1970-01-01 00:00:00  2147483647 seconds" +"%Y-%m-%d %T"
2038-01-19 03:14:07

$ date -d "1970-01-01 00:00:00  3147483648 seconds" +"%Y-%m-%d %T"
2069-09-27 05:00:48

$ date -d "1970-01-01 00:00:00  1113147483648 seconds" +"%Y-%m-%d %T"
37244-03-28 10:20:48

–//不过好像date命令不受影响.但愿我多虑了….

–//另外如果开启10046跟踪,里面的tim记录的’1970/1/1’开始的秒数乘以1000000.
*** 2017-08-24 11:06:59.156
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WAIT #140568569128584: nam=’SQL*Net message from client1′ ela= 10215533 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019156541
CLOSE #140568569128584:c=0,e=8,dep=0,type=1,tim=1503544019156653
=====================
PARSING IN CURSOR #140568569243528 len=17 dep=0 uid=83 oct=3 lid=83 tim=1503544019156841 hv=1745700775 ad=’61c8f7a0′ sqlid=’a2dk8bdn0ujx7′
select * from emp
END OF STMT
PARSE #140568569243528:c=0,e=133,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=3956160932,tim=1503544019156835
EXEC #140568569243528:c=0,e=59,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=3956160932,tim=1503544019157002
WAIT #140568569243528: nam=’SQL*Net message to client’ ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019157076
FETCH #140568569243528:c=0,e=99,p=0,cr=6,cu=0,mis=0,r=1,dep=0,og=1,plh=3956160932,tim=1503544019157226
WAIT #140568569243528: nam=’SQL*Net message from client’ ela= 827 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019158106
WAIT #140568569243528: nam=’SQL*Net message to client’ ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019158198
FETCH #140568569243528:c=0,e=61,p=0,cr=1,cu=0,mis=0,r=7,dep=0,og=1,plh=3956160932,tim=1503544019158238
WAIT #140568569243528: nam=’SQL*Net message from client’ ela= 619339 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019777623
WAIT #140568569243528: nam=’SQL*Net message to client’ ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=1503544019777726
FETCH #140568569243528:c=0,e=86,p=0,cr=1,cu=0,mis=0,r=6,dep=0,og=1,plh=3956160932,tim=1503544019777787
STAT #140568569243528 id=1 cnt=14 pid=0 pos=1 obj=87108 op=’TABLE ACCESS FULL EMP (cr=8 pr=0 pw=0 time=89 us cost=3 size=532 card=14)’

–//例子tim=1503544019156541测试:

SYS@book> select to_date(‘1970/1/1′,’yyyy-mm-dd’) + 1503544019156541/1e6/86400 from dual ;
TO_DATE(‘1970/1/1′,
——————-
2017-08-24 03:06:59

–//^_^,没有考虑时区.注意看下划线部分.而且丢失秒的精度,换成如下:
SYS@book> select to_timestamp(‘1970/1/1′,’yyyy-mm-dd’) + 1503544019156541/1e6/86400 from dual ;
TO_TIMESTAMP(‘1970/
——————-
2017-08-24 03:06:59

–//呃还是转换date类型.写成如下ok:

SYS@book> select to_timestamp(‘1970/1/1′,’yyyy-mm-dd’) +  NUMTODSINTERVAL(1503544019156541/1e6,’SECOND’) from dual ;
TO_TIMESTAMP(‘1970/1/1′,’YYYY-MM-DD’)+NUMTODSINTERVAL(1503544019156541/1E6,
—————————————————————————
2017-08-24 03:06:59.156541000

PS:如果您想和业内技术大牛交流的话,请加qq群(527933790)或者关注微信公众 号(AskHarries),谢谢!

转载请注明原文出处:Harries Blog™ » [20170825]2038.txt

赞 (0)

分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址