MySql 错误 1064 - 使用 MySQL WorkBench 创建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3797399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:15:45  来源:igfitidea点击:

MySql Error 1064 - Created using MySQL WorkBench

mysqlmysql-error-1064create-table

提问by Harsha M V

I created this using MySQL WorkBench

我使用 MySQL WorkBench 创建了这个

CREATE  TABLE IF NOT EXISTS `bakasura_new`.`cities` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) NOT NULL COMMENT 'City Name' ,
  `short_name` VARCHAR(255) NOT NULL COMMENT 'Short Name' ,
  `country_id` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_cities_countries` (`country_id` ASC) ,
ENGINE = InnoDB;

I am getting this error

我收到此错误

MySQL said: Documentation

#1064 - 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 '= InnoDB' at line 8

MySQL 说: 文档

#1064 - 你的 SQL 语法有错误;检查手册

对应于您的 MySQL 服务器版本,以便在第 8 行的“= InnoDB”附近使用正确的语法

回答by Daniel Vassallo

You have a dangling comma here:

这里有一个悬空的逗号:

INDEX `fk_cities_countries` (`country_id` ASC) ,

And you also have a missing parenthesis at the end:

而且最后还有一个缺少括号:

CREATE  TABLE IF NOT EXISTS `bakasura_new`.`cities` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) NOT NULL COMMENT 'City Name' ,
  `short_name` VARCHAR(255) NOT NULL COMMENT 'Short Name' ,
  `country_id` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_cities_countries` (`country_id` ASC)
) ENGINE = InnoDB;

回答by DrColossos

There is a )missing at the end of the last )

)最后的结尾有一个缺失)

INDEX `fk_cities_countries` (`country_id` ASC) )