【发布时间】:2021-02-01 01:42:45
【问题描述】:
我想将外键添加到名为“地址”的表中。
ALTER TABLE `students1`.`address`
ADD CONSTRAINT `id_country`
FOREIGN KEY ()
REFERENCES `students1`.`country` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION;
这个请求是由 MySQLWorkbench 自动生成的。 但是得到这个错误
ERROR 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 `students1`.`country` ()
ON DELETE NO ACTION
ON UPDATE NO ACT' at line 3
如何解决这个问题?
【问题讨论】:
-
这只是无效的 SQL。你到底想做什么?
-
我正在尝试将外键添加到另一个已经存在的表中。
标签: mysql sql foreign-keys mysql-workbench