转载请注明出处,谢谢!
MYSQL版本:5.6.46-log
TIMESTAMP 理解
TIMESTAMTP 所能存储的时间范围为:‘1970-01-01 00:00:01.000000’ 到 ‘2038-01-19 03:14:07.999999’。注意黑体的1秒,存为0秒,数据库会报超出范围的错误。
TIMESTAMTP 存储的为UTC标准时间,其对应单位如下所示:
TIMESTAMTP 秒
TIMESTAMP(3) 毫秒
TIMESTAMP(6) 微妙
CREATE TABLE `timestamptest` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`t1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '单位秒',
`t2` TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP (3) COMMENT '单位毫秒',
`t3` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP (6) COMMENT '单位微妙',
`t4` TIMESTAMP(7) NOT NULL DEFAULT CURRENT_TIMESTAMP (7) COMMENT '错误',
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4 COMMENT = 'timestamp测试';
执行如上建表SQL&