当我尝试通过如下更改查询将外键添加到已创建的表时,出现以下错误。有两个表 usertype 包含 usertypeid 字段作为主键和 account 表,其中 usertypeid 我想成为外键。
我正在使用以下查询,并且我知道该查询是正确的,但不知道为什么会出现此错误。
alter table account add constraint fk_usertypeid foreign key usertypeid references usertype(usertypeid) on update cascade on delete cascade;
我尝试执行查询时发生以下错误
#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 'references usertype(usertypeid) on update cascade on delete cascade' at line 1