In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you what the time functions of Mysql, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Mysql has plenty of time functions.
Filter conditions with seconds not equal to 0 in 1.mysql query time
Sql code
SECOND (t.file_time)
two。 Current time
Sql code
Now ()
3. A day ago,
Sql code
Select DATE_SUB (curdate (), INTERVAL 1 DAY)
4.timestamp default value
The weird problem of mysql timestamp field
Create a table statement:
Sql code
CREATE TABLE `testtimestamp` (
`id` INT NOT NULL AUTO_INCREMENT
`file_ time`TIMESTAMP NOT NULL
`scan_ time`TIMESTAMP NULL
`created` TIMESTAMP NOT NULL
`modified` TIMESTAMP NOT NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
After execution, the default value of file_time is CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
The default value of scan_time is NULL
The default values for created and modified are '0000-00-0000: 00: 00'
It's a strange question that the first timestamp field of the creation statement is CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
And when file_time is in update, if it is not in the set group, it will default to now ()!
This results in a default value, and if this field is not present in the update statement, the current time is populated by default.
Type of modification:
Sql code
ALTER TABLE `database`.`tablename` CHANGE COLUMN `columname`columname` TIMESTAMP NOT NULL DEFAULT '0000-00-0000: 0000'
These are all the contents of the article "what are the time functions of Mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.