創(chuàng)建數(shù)據(jù)表時失敗道伟,提示以下信息:
09-13-2016 07:47:49 ERROR o.h.t.h.SchemaUpdate [https-jsse-nio-443-exec-6] HHH000388: Unsuccessful: create table users (id bigint not null auto_increment, createdOn DATETIME DEFAULT CURRENT_TIMESTAMP, token varchar(33) not null unique, updatedOn DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, userName varchar(65) not null unique, primary key (id))09-13-2016 07:47:49 ERROR o.h.t.h.SchemaUpdate [https-jsse-nio-443-exec-6] Invalid default value for 'createdOn'
查找原因诚欠,發(fā)現(xiàn)是由于以下導致的:
createdOn DATETIME DEFAULT CURRENT_TIMESTAMP
updatedOn DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE
在http://www.mysqltutorial.org/MySQL-timestamp.aspx中有句話:
Note that since mysql 5.6.5, the DATETIME data type also has automatic initialization and automatic update feature. In addition, the DEFAULT_CURRENT_TIMESTAMP and ON UPDATE CURRENT TIMESTAMP attributes can be applied to multiple columns, not just 1 column in the previous versions.
即對于5.6.5之前的MySQL版本,不支持多條同時使用 DEFAULT CURRENT_TIMESTAMP和ON UPDATE CURRENT TIMESTAMP特性慰安,使用mysql -v查了下我現(xiàn)在使用的mysql版本為5.5.49,即不支持多條同時使用聪铺。因此將mysql更新至5.6.31化焕,問題解決。