我试图在MySQL中使用MySQL工作台创建外键。但出现错误在MySQL中创建外键
$ Executing:
ALTER TABLE `project_course`.`attendance`
ADD CONSTRAINT `FK_Student`
FOREIGN KEY ('idStudent')
REFERENCES `project_course`.`student` ('userid')
ON DELETE NO ACTION
ON UPDATE NO ACTION;
Operation failed: There was an error while applying the SQL script to the database.
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 ''idStudent')
REFERENCES `project_course`.`student` ('userid')
ON DELETE NO A' at line 3
SQL Statement:
ALTER TABLE `project_course`.`attendance`
ADD CONSTRAINT `FK_Student`
FOREIGN KEY ('idStudent')
REFERENCES `project_course`.`student` ('userid')
ON DELETE NO ACTION
ON UPDATE NO ACTION
如何更改?我用这个引号。我必须使用哪些引号? –
谢谢/我用括号中没有引号的列名和它的执行。 –
@ M.Namiz'这个引用是文字的,当你想给一个值作为字符串,就像插入语句中的定义一样,你应该使用反斜杠,在windows上的Esc键下 – Musa