oracle DATE 和 TIMESTAMP 的区别

Difference between oracle DATE and TIMESTAMP(oracle DATE 和 TIMESTAMP 的区别)
本文介绍了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 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)