Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create time automatically in mysql

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to create time automatically in mysql. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

The first is defined by ddl

CREATE TABLE `times` (`room`varchar (25551) DEFAULT NULL, `user`User`255DEFAULT NULL, `score`int (11) DEFAULT NULL, `id`int (11) NOT NULL AUTO_INCREMENT, `update_ time`datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'creation time', `update_ time`datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8

Second, modify the table design directly through the tool

Third, fields can also be modified through sql statements.

-- modify create_time to set the default time CURRENT_TIMESTAMP ALTER TABLE `upload `MODIFY COLUMN `create_ time`time';-- add update_time to set the default time CURRENT_TIMESTAMP to set the update time to ON UPDATE CURRENT_TIMESTAMP ALTER TABLE ``add `add COLUMN `update_ time`datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT' On how to automatically create time in mysql to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report