In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to deal with the problem of automatically adding default values in multiple timestamp fields of MySQL. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
MySQL version 5.6.14
Construction table sentence
Drop table live_shrimp_info
CREATE TABLE `live_shrimp_ info` (
`LiveID` bigint (20) NOT NULL COMMENT 'live ID'
`SummonStartTime`SummonStartTime` timestamp (3) NOT NULL COMMENT 'call period start time'
`SummonEndTime` timestamp (3) NOT NULL COMMENT 'call period end time'
`CaptureStartTime`CaptureStartTime` timestamp (3) NOT NULL COMMENT 'start time of capture'
`CaptureEndTime`CaptureEndTime` timestamp (3) NOT NULL COMMENT 'end of capture period'
`CreateTime`CreateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time'
`UpdateTime`UPDAT'
PRIMARY KEY (`LiveID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
After the table is created, use the show create table live_shrimp_info; query
CREATE TABLE `live_shrimp_ info` (
`LiveID` bigint (20) NOT NULL COMMENT 'live ID'
`SummonStartTime`SummonStartTime` timestamp (3) NOT NULL DEFAULT CURRENT_TIMESTAMP (3) ON UPDATE CURRENT_TIMESTAMP (3) COMMENT 'call time'
`SummonEndTime` timestamp (3) NOT NULL DEFAULT '0000-00-
`CaptureStartTime` timestamp (3) NOT NULL DEFAULT '0000
`CaptureEndTime` timestamp (3) NOT NULL DEFAULT '0000
`CreateTime`CreateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time'
`UpdateTime`UPDAT'
PRIMARY KEY (`LiveID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
What? Why are there so many default values?
That's what's funny about MySQL. It thinks you lack a default value. I added it for you.
The first field of timestamp and not null is automatically added by MySQL.
DEFAULT CURRENT_TIMESTAMP () ON UPDATE CURRENT_TIMESTAMP ()
Other fields of timestamp and not null are automatically added by MySQL.
DEFAULT '0000-00-0000: 00VOV 00'
The above is all the content of this article entitled "how to deal with the problem of automatically adding default values for multiple timestamp fields in MySQL". Thank you for reading! Hope to share the content to help you, more related 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.