When creating a time field DEFAULT CURRENT_TIMESTAMP Indicates that when inserting data, the default value of this field is the current time ON UPDATE CURRENT_TIMESTAMP Indicates that every time this data is updated, the field will be updated to the current time These two operations are maintained by the MySQL database itself, so the two fields [Creation Time] and [Update Time] can be generated based on this feature, and no code is required to maintain them. as follows: CREATE TABLE `mytest` ( `text` varchar(255) DEFAULT ''COMMENT 'content', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time' )ENGINE=InnoDB DEFAULT CHARSET=utf8; Can be operated directly through navicat's visual interface So how do you set a specific default time? As follows, note that there are two single quotes The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to use sed command to efficiently delete specific lines of a file
>>: Webpack builds scaffolding to package TypeScript code
MySQL database is widely used, especially for JAV...
In this article, I will explain in detail how to ...
This article uses an example to describe the crea...
Table of contents Basic concepts of components Th...
Table of contents 1. Introduction 2. es5 method 3...
Before officially using Docker, let's first f...
CSS media query has a very convenient aspect rati...
<br />This article is mainly to let beginner...
Table of contents introduce Object attributes in ...
Students who make websites often find that some n...
<br />Previous article: Web Design Tutorial ...
In this system, the # sign represents the root us...
Although W3C has established some standards for HT...
Open any web page: for example, http://www.baidu....
Question How to access the local database in Dock...