日期如何存储在Oracle中? [英] How are dates stored in Oracle?

查看:203
本文介绍了日期如何存储在Oracle中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

日期如何存储在Oracle中?例如,我知道大多数系统使用Epoch时间来确定它是什么时间。通过计算从1970年1月1日开始的几秒钟。甲骨文是否也这样做?



我问这个问题的原因是我注意到,如果您在Oracle中使用两个日期,并减去它们,您会得到两天之间的浮点数。



示例

 (Sysdate  -  dateColumn)

将返回此类型(取决于时间)

  3.32453703703703703703703703703703703704 

现在Oracle正在进行转换并将该格式吐出,或者Oracle在某个时间段内存储多少天? (喜欢时代)

解决方案

两种类型12和13



http://oraclesniplets.tumblr.com / post / 1179958393 / my-oracle-support-oracle-database-69028-1



类型13

 从双重选择dump(sysdate); 
Typ = 13 Len = 8:220,7,11,26,16,41,9,0

日期数据类型的格式是

字节1 - 基数256年修正值:220
2 - 基数256年:256 * 7 = 1792 + 220 = 2012
3 - 月:11
4 - 日:26
5 - 时间:16
6 - 分钟:41
7 - 秒:09
8 - 未使用

2012-11-26 16:41:09



类型12

 从标签中选择转储(begindate) 
Typ = 12 Len = 7:100,112,2,7,1,1,1

日期数据类型的格式为

字节1 - 世纪(超出100)100 - 100 = 00
字节2 - 年(超过100)112 - 100 = 12
字节3 - 月= 2
字节4 - 天= 7
字节5小时(超出1)1 - 1 = 0
字节6分钟(超出1)1 - 1 = 0
字节7 - 秒(超出1)1 - 1 = 0

0012-02-07 00:00:00


How are dates stored in Oracle? For example I know most systems use Epoch time to determine what time it is. By calculating how many seconds away from January 1st 1970. Does Oracle do this as well?

The reason I am asking this is I noticed if you take two dates in Oracle and subtract them you get a floating point of how many days are between.

Example

(Sysdate - dateColumn)

would return something like this (depending on the time)

3.32453703703703703703703703703703703704

Now is Oracle doing the conversion and spitting that format out, or does Oracle store dates with how many days it is away from a certain time frame? (Like Epoch time)

解决方案

The are two types 12 and 13

http://oraclesniplets.tumblr.com/post/1179958393/my-oracle-support-oracle-database-69028-1

Type 13

select dump(sysdate) from dual;
Typ=13 Len=8: 220,7,11,26,16,41,9,0

The format of the date datatype is

Byte 1 - Base 256 year modifier : 220
2      - Base 256 year : 256 * 7 = 1792 + 220 = 2012
3      - Month : 11
4      - Day : 26
5      - Hours : 16
6      - Minutes : 41
7      - Seconds : 09
8      - Unused

2012-11-26 16:41:09

Type 12

select dump(begindate) from tab;
Typ=12 Len=7: 100,112,2,7,1,1,1

The format of the date datatype is

byte 1 - century (excess 100)  100 - 100 = 00
byte 2 - year (excess 100)  112 - 100 = 12
byte 3 - month = 2
byte 4 - day = 7
byte 5 - hour (excess 1) 1 - 1 = 0
byte 6 - minute (excess 1) 1 - 1 = 0
byte 7 - seconds (excess 1) 1 - 1 = 0

0012-02-07 00:00:00

这篇关于日期如何存储在Oracle中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆