无法在 MySQL 8.0 中创建表格。

huangapple go评论116阅读模式
英文:

Cannot create table in myslq 8.0

问题

我在尝试在MySQL命令行中创建表格时遇到错误,如图所示点击此处查看图像描述。我试图创建表格,但出现了语法错误1064,提示我在语法中有错误。

英文:

I am getting an error when i am trying to create a table in mysql command line as shown in the imageenter image description here

I was trying to create a table and got a syntax error 1064 stating I have an error in the syntax.

答案1

得分: 1

SQL语法中存在错误。在表名后面的CREATE语句中缺少逗号。

CREATE TABLE favorite_food (
  person_id SMALLINT UNSIGNED,
  food varchar(20),
  PRIMARY KEY (person_id, food),
  FOREIGN KEY (person_id) REFERENCES person (person_id)
);
英文:

There is an error in your SQL syntax. The CREATE statement does not contain a comma after the table name.

  CREATE TABLE favorite_food (
  person_id SMALLINT UNSIGNED,
  food varchar(20),
  PRIMARY KEY (person_id,food),
  FOREIGN KEY(person_id)  REFERENCES person (person_id)
  );

答案2

得分: 0

创建表favorite_food(
person_id SMALLIT UNSIGNED,
food VARCHAR(20),
PRIMARY KEY (person_id,food),
FOREIGN KEY(person_id) REFERENCES person (person_id)
);

英文:

CREATE TABLE favorite_food(
person_id SMALLIT UNSIGNED,
food VARCHAR(20),
PRIMARY KEY (person_id,food),
FOREIGN KEY(person_id) REFERENCES person (person_id));

huangapple
  • 本文由 发表于 2023年7月11日 12:53:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658804.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定