安装 DataSphereStudio-Doc 报错:Invalid default value for ‘update_time‘

0.完整报错:

安装 DataSphereStudio-Doc,在安装Linkiss时,报错

ERROR 1067 (42000) at line 32 in file: '/usr/local/dss_linkis/linkis/db/linkis_ddl.sql': Invalid default value for 'update_time'
Failed to  + source linkis_ddl.sql
***********Error: failed to  + install Linkis

1.分析

查看具体sql发现是 datetime 的问题

DROP TABLE IF EXISTS `linkis_ps_configuration_config_value`;
CREATE TABLE linkis_ps_configuration_config_value(
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `config_key_id` bigint(20),
  `config_value` varchar(200),
  `config_label_id`int(20),
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE INDEX(`config_key_id`, `config_label_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DataSphere Studio 文档中提到需求 mysql 5.5+

  • 我找了一台mysql 5.5.47测试,[Err] 1067 - Invalid default value for ‘update_time’
  • 我另一台mysql 5.7运行上述sql正常

看来的确是mysql版本的问题,必须得升级mysql版本才能解决!

3.原因

查阅
MySQL5.6 官方文档
发现:

As of MySQL 5.6.5, TIMESTAMP and DATETIME columns can be automatically initializated and updated to the current date and time (that is, the current timestamp). Before 5.6.5, this is true only for TIMESTAMP, and for at most one TIMESTAMP column per table

即在MySQL5.6版本后DATETIME类型字段才可以设置默认值与自动更新,之前的仅TIMESTAMP。
原去除默认值即可正常跑

你可能感兴趣的:(总结,sql,mysql,数据库)