In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Let's learn about the date and time type in the MySQL column type. I believe you will benefit a lot after reading it. The text is not much in essence. I hope the date and time type in the MySQL column type is what you want.
Column type (data type)
The so-called column type, in fact, refers to the data type, that is, a unified classification of data, from a system point of view is to be able to use a unified way of management, better use of limited space.
In SQL, data types are divided into three categories: numerical type, string type and date-time type.
Date and time type
Date-time data, as the name implies, is the data type used to represent date and time. There are five types of data, namely:
Datetime: date time, formatted as yyyy-MM-dd HH:mm:ss, indicating a range from 1000 to 9999, with a zero value, that is, 0000-00-00 000000
Date: date, which is the date part of datetime
Time: time, or time period, is between a specified time interval, including positive and negative time
Timestamp: timestamp, but it is not really a timestamp. It has been calculated since 1970 and has the same format as datetime.
Year: year, there are two formats, year (2) and year (4).
Execute the following SQL statement to create a date schedule for testing:
-- creation date schedule create table my_date (D1 datetime, D2 date, D3 time, D4 timestamp, D5 year) charset utf8
When we insert data, the time in the date-time type can be negative, or even a large negative number; year, can use 2-bit data insertion, can also use 4-bit data insertion; timestamp, as long as the current record is updated, the field will be automatically updated to the current time, and the timestamp type is non-empty by default.
-- insert the test data insert into my_date values ('2017-05-06 13 1500 charge 2017-05-06 6); insert into my_date values (' 05-05-06 13 13 1500 charge 2017-05-06 13); insert the test data 2017-05-06 13 May-06 13 1500 theory 2017-05-06 13 May 13 1500 theory 2017-05-06 13 13 15 race 1500 camera 69) Insert into my_date values ('2017-05-06 13-15-50-06 13-15-05-06-17-05-06 13-15-15-00)
As shown in the figure above, the above three records have been inserted successfully. Next, let's verify whether the field d4 of the timestamp type is automatically updated when the record is updated:
Update the record and verify that fields of timestamp type automatically update update my_date set D1 = '2017-05-06 13 2440 00' where D5 = 1970
As shown in the figure above, it is clear that all our conclusions have been verified.
After reading this article on date-time types in MySQL column types, many readers will want to know more about it. For more industry information, you can follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.