时间类型
类型 | 范围 |
---|---|
DATE | ‘1000-01-01’ to ‘9999-12-31’ |
DATETIME | ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’ |
TIMESTAMP | ‘1970-01-01 00:00:01’ UTC to '2038-01-19 03:14:07’UTC |
设置不为空的默认值
//去除空值
UPDATE `pre_tabel` SET `time`='1970-01-02 00:00:00' WHERE `time`<'1970-01-02 00:00:00';
UPDATE `pre_tabel` SET `time`='1970-01-02 00:00:00' WHERE ISNULL(time);
//设置默认值
ALTER TABLE `pre_tabel` MODIFY COLUMN `time` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '时间';