一、错误信息
CREATE TABLE `file` (
`id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件md5',
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`create_time` datetime(0) NULL DEFAULT NULL,
`update_time` datetime(0) NULL DEFAULT NULL,,
PRIMARY KEY (`id`)
)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(0) NULL DEFAULT NULL,
`update_time` datetime(0) NULL DEFAULT NULL,
`tena' at line 3
二、解决方法文章来源:https://www.toymoban.com/news/detail-690946.html
问题发现是第三行,那就是datetime字段,在网上查询是mysql版本时间字段不能设置为0。给一个默认值,直接删除 (0) NULL文章来源地址https://www.toymoban.com/news/detail-690946.html
CREATE TABLE `file` (
`id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件md5',
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
##默认是1970-01-01 00:00:00,中国时间要加8
`create_time` datetime DEFAULT '1970-01-01 08:00:00',
`update_time` datetime DEFAULT '1970-01-01 08:00:00',
PRIMARY KEY (`id`)
)
到了这里,关于mysql数据库运行sql:datetime(0) NULL DEFAULT NULL报错【杭州多测师_王sir】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!