如何在Oracle中处理闰秒

前端之家收集整理的这篇文章主要介绍了如何在Oracle中处理闰秒前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
今天晚上将有一个闰秒添加到时钟,在一天的最后一个小时的最后一分钟将有61秒.
2015-06-30 23:59:60

但是,Oracle只能在一分钟内支持最多60秒:

TO_DATE( '2015-06-30 23:59:60','YYYY-MM-DD HH24:MI:SS' )

错误与:

ORA-01852: seconds must be between 0 and 59

SELECT TO_DATE( '2015-06-30 23:59:59','YYYY-MM-DD HH24:MI:SS' ) + INTERVAL '1' SECOND AS Incr_Second_Before,TO_DATE( '2015-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS' ) - INTERVAL '1' SECOND AS Decr_Second_After
FROM   DUAL

给出输出

|     INCR_SECOND_BEFORE |      DECR_SECOND_AFTER |
|------------------------|------------------------|
| July,01 2015 00:00:00 | June,30 2015 23:59:59 |

有没有办法在Oracle中处理闰秒?

从MOS-

Insert leap seconds into a timestamp column fails with ORA-01852 (Doc
ID 1553906.1)

APPLIES TO:

Oracle Database – Enterprise Edition – Version 8.1.7.4 and later

Oracle Database – Standard Edition – Version 8.1.7.4 and later

Information in this document applies to any platform.

SYMPTOMS:

An attempt to insert leap seconds into a timestamp column,fails with:
ORA-01852: seconds must be between 0 and 59

CAUSE

It is not possible to store >59 sec value in a date or timestamp
datatype

SOLUTION

To workaround this issue,the leap second record can be stored in a
varchar2 datatype instead e.g.

sql> create table test (val number,t varchar2(30));

Table created.

sql> insert into test values(123,'2012-06-30T23:59:60.000000Z');

1 row created.

不是最好的解决方案,而是唯一的解决方案.

猜你在找的Oracle相关文章