CREATE TABLE IF NOT EXISTS Grade (
StudentNumber VARCHAR(10) NOT NULL,
ClassNumber INT(10) NOT NULL,
Grade DOUBLE(3),
PRIMARY KEY(StudentNumber, ClassNumber),
FOREIGN KEY(StudentNumber)REFERENCES student(StudentNumber),
FOREIGN KEY(ClassNumber)REFERENCES class(ClassNumber)
)
MySQL说:文档
1064-您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册以使用正确的语法 靠近'),PRIMARY KEY(StudentNumber,ClassNumber),FOREIGN KEY(StudentNumber)REFERENC'在第4行
答案 0 :(得分:2)
如果您使用double,则必须添加应包含的位数:
CREATE TABLE IF NOT EXISTS Grade (
StudentNumber VARCHAR(10) NOT NULL,
ClassNumber INT(10) NOT NULL,
Grade DOUBLE(3, 2),
PRIMARY KEY(StudentNumber, ClassNumber),
FOREIGN KEY(StudentNumber)REFERENCES student(StudentNumber),
FOREIGN KEY(ClassNumber)REFERENCES class(ClassNumber) )