Date and timestamp types for Oracle databases

Source: Internet
Author: User

The 1.date type stores data in the format of month-date seconds and minutes, and can be accurate to the second

The timestamp type stores data in the format of month-day seconds and minutes, and can be accurate to nanoseconds (9-bit)

2.date type

Date type data can be displayed to the date of month or month, and also to the date of day and minute, mainly to see the accuracy of storage data

Note: The display here refers to the display of data seen from the Plsql visualizer

1) Storage date only display month Day

2) No time, minutes, minutes, minutes, minutes, minutes, minutes, or seconds, 00:00:00, only show the date

3) Note: There is another case of error

4) The day of the month and seconds will be displayed.

Note: The format of the date type stored in the database must be day and night, but about why there is no time when the problem is not displayed, is plsql This visual tool for no minutes or seconds or minutes of the second for 00:00:00 to do the processing, in this case does not show when seconds, and other tools I have not tried

3.timestamp can store data with a maximum accuracy of nanoseconds (9), but the default storage precision is microseconds (6)

Oracle definition Syntax: TIMESTAMP [(Precision)]
The precision range is 0 to 9, and the default is 6. The default can be written timestamp or timestamp (6)

--The build table contains the timestamp type. SQL> CREATE TABLE Tb__order (create_time timestamp); SQL> INSERT INTO Tb__order values (To_timestamp (' 2006-12-01 12:12:09.123456789 ', ' yyyy-mm-dd HH24:MI:SS.FF ' ) ; When you create a table, you do not specify the precision range of the timestamp, so the default is 6, when the data is added, FF is the precision range, and the added data is 9 bits, then the stored data is rounded to 6 bits, so the storage result is ' 2006-12-01 12:12:09.123457 ' If you want to use higher precision, you need to create a table when you specify. (generally not available) SQL> CREATE TABLE Tb__order (create_time timestamp (9));

1) query system time can be accurate to 9

2) default query accurate to 6

3) operation timestamp type as long as not between 0-9 will be error

4.current_date and Current_timestamp

Mybtais's Mapper.xml file

1) When current_date, the current time is stored in the month and day time and minute format

The corresponding database type is date

2) When current_timestamp, the data stored is accurate to 6 bits

The corresponding database type is timestamp

Date and timestamp types for Oracle databases

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.