CREATE TABLE `tab1` (
`tab1_id` VARCHAR(11) DEFAULT NULL,
`create` TIMESTAMP(3) NULL DEFAULT NULL,
`create2` DATETIME(3) DEFAULT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8
SELECT * FROM tab1;
TIMESTAMP(3)与 DATETIME(3)意思是保留3位毫秒数
TIMESTAMP(6)与 DATETIME(6)意思是保留6位毫秒数
修改已存在的表字段示例:ALTER TABLE tb_financial MODIFY CREATE_TIME DATETIME(3) DEFAULT NULL COMMENT '录入时间';
插入日期可以用NOW(3)来控制精确的毫秒数,SELECT CURRENT_TIMESTAMP(3);也是可以的
http://www.cnblogs.com/shihaiming/p/5853595.html
DEFAULT values in MySQL must be constants. They can't be functions or expressions (with the exception of CURRENT_TIMESTAMP).
Source: http://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html
http://stackoverflow.com/questions/27601482/add-date-time-as-default-value
时间: 2024-09-12 02:29:20