Database storage time data with timestamp good or varchar good

Source: Internet
Author: User

The date data is basically dated, with VARCHAR2 or char, the benefits are as follows:
1, data specification. Date is validated for the legal date type, including leap year February. Avoid the problem that the character type variable produces a month number 32nd, the date length is not correct, the date format is not uniform and so on. There has been a painful experience, the face of the character type of 2013111 this data do not know whether it is November 1 or January 11, just want to say th ...
2, retrieval efficiency. If you often take this date behind the where, or you want to Jianjian the word index. You can try the difference between date and char, let alone partition index.
3, convenient calculation. When you calculate the two date difference days, you are willing to write a function of char to Judge Otsuki Yue Leap month, or directly take the date variable date1-date2 it? Do you want to write a large section of the stored procedure, or update the table set DATE1=DATE1+50 directly when you are going to defer the date in bulk for 50 days?

If the date variable is a char (14), it is not worth being created alone, and since it exists, it must have special meaning and use value.

Wet Dreams's Bride
Links: https://www.zhihu.com/question/25541686/answer/31068450
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

Database storage time data with timestamp good or varchar good

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.