Comparison of Date,datetime,int,timestamp and time types in MySQL database

Source: Internet
Author: User

Datetime

Used when you need a value that contains both date and time information. MySQL retrieves and displays the datetime value in ' yyyy-mm-dd HH:MM:SS ' format, supported by ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '. 8 bytes of storage.

DATE

When you need only a date value, there is no time part. MySQL retrieves and displays the date value in ' YYYY-MM-DD ' format, supported by ' 1000-01-01 ' to ' 9999-12-31 '.

TIMESTAMP

A column type provides a type that you can use to automatically mark an INSERT or update operation with the current date and time. The timestamp value cannot be earlier than 1970 or later than 2037. 4 bytes of storage.

Time

Represents the time of day. MySQL retrieves and displays the time value in the "HH:MM:SS" format. The range of support is ' 00:00:00 ' to ' 23:59:59 '.

Int

4 bytes of storage, storage space is less than datatime, int index storage space is relatively small, sorting and query efficiency is relatively high; poor readability, unable to visualize the data, can make you angry

Comparison of Date,datetime,int,timestamp and time types in MySQL database

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.