In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to set the default value for datetime in navicat. I hope you will get something after reading this article. Let's discuss it together.
When using navicat to design fields in a table, you can set default values for fields, but fields of type datetime cannot be set without default.
Because the default value of the current field of MySQL does not support functions, it is not possible to set the default value in the form of create_time datetime default now (). The alternative is to use TIMESTAMP types instead of DATETIME types.
The TIMESTAMP column type automatically marks the operation of INSERT or UPDATE with the current date and time. If you have more than one TIMESTAMP column, only the first one is automatically updated.
Automatic updating of the first TIMESTAMP column occurs under any of the following conditions:
1. Column values are not explicitly specified in an INSERT or LOAD DATA INFILE statement.
two。 Column values are not explicitly specified in one UPDATE statement and other columns change the value. Note that a UPDATE sets a column to its existing value, which will not cause the TIMESTAMP column to be updated, because if you set a column to its current value, MySQL ignores the change for the sake of efficiency. )
3. You explicitly set TIMESTAMP as NULL.
4. TIMESTAMP columns other than the first can also be set to the current date and time, as long as the column is set to NULL, or NOW ().
So just choose the date type as timestamp to allow null.
CREATE TABLE test (uname varchar (50) NOT NULL,updatetime timestamp NULL DEFAULTCURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8
If you want to operate under navicat, set the field to timestamp, and then write the default value CURRENT_TIMESTAMP.
After reading this article, I believe you have some understanding of "how to set default values for datetime in navicat". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.