oracle DATE 和 TIMESTAMP 的区别 [英] Difference between oracle DATE and TIMESTAMP

查看:36
本文介绍了oracle DATE 和 TIMESTAMP 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Oracle DATE 和 TIMESTAMP 类型有什么区别?两者都有日期和时间组件?还有这些日期类型在Java中对应的类型是什么?

What are the difference between Oracle DATE and TIMESTAMP type? Both have date and time component? Also what is corresponding type in Java for these date types?

推荐答案

DATE 和 TIMESTAMP 具有相同的大小(7 个字节).这些字节用于存储世纪、十年、年、月、日、小时、分钟和秒.但是 TIMESTAMP 允许存储其他信息,例如小数秒(11 字节)和带时区的小数秒(13 字节).

DATE and TIMESTAMP have the same size (7 bytes). Those bytes are used to store century, decade, year, month, day, hour, minute and seconds. But TIMESTAMP allows to store additional info such as fractional seconds (11 bytes) and fractional seconds with timezone (13 bytes).

TIMESTAMP 被添加为符合 Oracle 的 ANSI.在此之前,它只有 DATE.

TIMESTAMP was added as an ANSI compliant to Oracle. Before that, it had DATE only.

在一般情况下,您应该使用 DATE.但如果需要时间精度,请使用 TIMESTAMP.

In general cases you should use DATE. But if precision in time is a requirement, use TIMESTAMP.

关于 Java,来自 Oracle JDBC 驱动程序的 oracle.sql.DATE 类提供 Oracle 日期/时间戳数据类型与 Java 类 java.sql.Date、java.sql.Time 和 java.sql.Timestamp 之间的转换.

And about Java, the oracle.sql.DATE class from Oracle JDBC driver, provides conversions between the Oracle Date/Timestamp data type and Java classes java.sql.Date, java.sql.Time and java.sql.Timestamp.

这篇关于oracle DATE 和 TIMESTAMP 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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