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
The backend uses the thinkphp3.2.3 framework. If ...
The blogger hasn't used MySQL for a month or ...
1. Docker Network Mode When docker run creates a ...
Preface: When you execute a SQL statement in MySQ...
When making a web page, you sometimes use a dividi...
Table of contents 1. Learning Objectives 1.1. Mas...
Recently, I used the webSocket protocol when work...
Table of contents JavaScript Objects 1. Definitio...
Preparation 1. Start the virtual machine 2. git t...
This article will discuss these 4 principles as t...
Table of contents 1. CentOS7+MySQL8.0, yum source...
After the release of CentOS8.0-1905, we tried to ...
method: By desc: Neither can be achieved: Method ...
This tag is not part of HTML3.2 and is only suppo...
By adding the current scroll offset to the attrib...