我正在尝试在MYSQL 5.7.23(phpmyadmin)上创建具有默认时间戳的表
CREATE TABLE mytable(
id MEDIUMINT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:01',
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY(id)
);
答案 0 :(得分:1)
TIMESTAMP值的范围从UTC的“ 1970-01-01 00:00:01”到UTC的“ 2038-01-19 03:14:07”
所以您应该使用
created_at TIMESTAMP DEFAULT '1970-01-01 00:00:01',
或RaymondNijland的建议
created_at TIMESTAMP DEFAULT 0
或更改为
created_at datetime DEFAULT '1900-01-01 00:00:01',