SQL:符号名称是预期的

时间:2017-03-08 19:43:27

标签: mysql

尝试将其实现到数据库中,其他所有类似工具到目前为止都已有效。

create table participation (
    team_id int(11) not null,
    driver_id int(11) not null,
    race_id int(11) not null,
    points_earned int(11),
constraint part_pk primary key (team_id, driver_id, race_id),
constraint part_fk foreign key (team_id) references team (team_id) ON update cascade,
constraint part_fktwo foreign key (driver_id) references driver (driver_id) ON update cascade,
constraint part_fkthree foreign key (race_id) references race (race_id) ON update cascade,
)
engine=innodb;

在最后一个括号处出错。

1 个答案:

答案 0 :(得分:2)

在查询结尾处有一个额外的逗号(最后一个外键约束):

create table participation (
    team_id int(11) not null,
    driver_id int(11) not null,
    race_id int(11) not null,
    points_earned int(11),
    constraint part_pk primary key (team_id, driver_id, race_id),
    constraint part_fk foreign key (team_id) references team (team_id) ON update cascade,
    constraint part_fktwo foreign key (driver_id) references driver (driver_id) ON update cascade,
    constraint part_fkthree foreign key (race_id) references race (race_id) ON update cascade
)
engine=innodb;