mysql设置create_time update_time自动获取时间

来源:这里教程网 时间:2026-03-01 15:39:23 作者:
DROP TABLE IF EXISTS
comments
; CREATE TABLE
comments
(
id
int(11) NOT NULL AUTO_INCREMENT,
postid
int(11) DEFAULT NULL,
content
varchar(1024) DEFAULT NULL,
fromid
int(11) DEFAULT NULL,
touserid
int(11) DEFAULT NULL,
parentid
int(11) DEFAULT NULL,
create_time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time
timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (
id
) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4

相关推荐