我是 MySQL 的初学者
每当我尝试向字段添加外键时,都会产生此错误:
ERROR 1064 (42000): 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 'ADD FOREIGN KEY ID
这是添加外键的代码:
ALTER TABLE 'table_name'
ADD CONSTRAINT 'FK_FKName'
ADD FOREIGN KEY table_name(column_name)
REFERENCES OtherTable_name(OtherTable_column_name);
请尝试帮助我
最佳答案
你可以尝试没有限制名称:
ALTER TABLE 'table_name'
ADD FOREIGN KEY table_name(column_name)
REFERENCES OtherTable_name(OtherTable_column_name);
关于mysql - MySQL 中的外键关系错误。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23677115/