我試圖在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