In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Differences in date types and their uses
There are five date types for MySQL, which are date, time, year, datetime, and timestamp.
Type byte format usage whether support setting system default date3YYYY-MM-DD date value does not support time3HH:MM:SS time value or duration does not support year1YYYY year does not support datetime8YYYY-MM-DD HH:MM:SS date and time mixed value does not support timestamp4YYYYMMDD HHMMSS mixed date and time, can be used as time stamp support
Application scenarios:
In the data table, it is not necessary for the application to record when each piece of data was created, but the data database obtains the current time to record the creation time automatically; in the database, to record when each piece of data was modified does not need the application to record it, but the data database acquires the current time to record the modification time automatically.
Implementation method:
Set the field type to TIMESTAMP and the default value to CURRENT_TIMESTAMP
Examples of applications:
MySQL script implementation use case
`create_ time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time', `datalevel` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time', `datalevel` tinyint (1) whether DEFAULT'1' COMMENT 'has been deleted (0 deletion / 1 normal)', ALTER TABLE table_nameADD COLUMN create_time datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time'; ALTER TABLE table_nameADD COLUMN update_time datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time' ALTER TABLE table_nameADD COLUMN datalevel tinyint (1) whether DEFAULT'1' COMMENT 'has been deleted (0 deletion / 1 normal)'
MySQL creates a normal index
ALTER TABLE projectfile ADD INDEX (fileuploadercode, projectid)
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support.
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.