【问题标题】:ERROR 1064 (42000): Error near 'Match( match_id INT(30) NOT NULL, club1_id CHAR(5), club1_score_id INT(30), club' at line 1错误 1064 (42000):第 1 行的“Match(match_id INT(30) NOT NULL, club1_id CHAR(5), club1_score_id INT(30), club' 附近出错
【发布时间】:2015-10-25 00:48:47
【问题描述】:

不断收到此错误:

ERROR 1064 (42000):您的 SQL 语法有错误;检查 与您的 MySQL 服务器版本相对应的手册 'Match(match_id INT(30) NOT NULL, club1_id) 附近使用的语法 CHAR(5), club1_score_id INT(30), club' 在第 1 行

尝试使用一些外键创建此表:

CREATE TABLE Match(
    match_id INT(30) NOT NULL,
    club1_id CHAR(5),
    club1_score_id INT(30),
    club2_id CHAR(5),
    club2_score_id INT(30),
    start_time TIME,
    end_time TIME,
    day INT(2),
    event_id INT(30),
    Primary Key(match_id),
    Foreign Key(club1_id) REFERENCES Club(club_id),
    Foreign Key(club2_id) REFERENCES Club(club_id),
    Foreign Key(club1_score_id) REFERENCES Score(score_id),
    Foreign Key(club2_score_id) REFERENCES Score(score_id),
    Foreign Key(event_id) REFERENCES Event(event_id));

但看不出有什么问题。帮忙?

这是数据库设计。也不介意一些反馈。

Database Design

【问题讨论】:

  • 尝试在第一行的 Match 和 (
  • @scaisEdge 试过了,还是有问题。其他表之间也没有空格,并且有效。

标签: mysql mysql-error-1064


【解决方案1】:

Match 是保留字。我建议将其更改为Matches,这样您在使用时就不必引用它。我通常用复数命名我的表,因为它们包含多个实体,并且复数不太可能与保留字冲突。

保留字列表为here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-23
    • 2013-10-19
    • 2021-02-16
    • 2022-01-09
    • 2021-10-05
    • 2021-05-03
    • 1970-01-01
    • 2021-09-23
    相关资源
    最近更新 更多