11.3.5 Automatic Initialization and Updating for TIMESTAMP and DATETIME 原文地址:https://dev.mysql.com/doc/refman/5.6/en/timestamp-initialization.html As of MySQL 5.6.5, TIMESTAMP and DATETIME columns can be automatically initializated and updated to the
执行如下SQL创建表: CREATE TABLE aa ( a INT, b TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, c TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) 报错如图所示: 两个新增时自动更新的时间也不行,只能有一个,大家可以去试试
自动更新修改时间: mysql> create table z(a int ,b timestamp on update current_timestamp); mysql> insert into z ,current_timestamp; mysql> select * from z; +------+---------------------+ | a | b | +------+---------------------+ | | -- :: | +------+--------