使用外键创建数据库 table 时出现错误 #1064
I got error #1064 while making a database table with Foreign key
我正在为我的学校项目制作一个 table,但在第 2 行出现 #1064 错误
CREATE TABLE markah (
kodKursus int(4),
FOREIGN KEY REFERENCES kursus(kodKursus),
kodAkaun int(4) not null,
FOREIGN KEY REFERENCES akaun(kodAkaun),
jumlahMarkah int(10) not null,
jumlahJawabBetul int(10) not null,
jumlahJawabKesalahan int(10) not null,
jumlahMasaGuna time(6) not null,
FOREIGN KEY REFERENCES masa(jumlahMasaGuna),
kodItemDapat int(4),
FOREIGN KEY REFERENCES item(kodItemDapat)
);
您缺少每个 FOREIGN KEY REFERENCES
上的外键。根据需要修改以下内容:
CREATE TABLE markah (
kodKursus int(4),
FOREIGN KEY (foreignKeyToComplete) REFERENCES kursus(kodKursus),
kodAkaun int(4) not null,
FOREIGN KEY (foreignKeyToComplete) REFERENCES akaun(kodAkaun),
jumlahMarkah int(10) not null,
jumlahJawabBetul int(10) not null,
jumlahJawabKesalahan int(10) not null,
jumlahMasaGuna time(6) not null,
FOREIGN KEY (foreignKeyToComplete) REFERENCES masa(jumlahMasaGuna),
kodItemDapat int(4),
FOREIGN KEY (foreignKeyToComplete) REFERENCES item(kodItemDapat)
);
我正在为我的学校项目制作一个 table,但在第 2 行出现 #1064 错误
CREATE TABLE markah (
kodKursus int(4),
FOREIGN KEY REFERENCES kursus(kodKursus),
kodAkaun int(4) not null,
FOREIGN KEY REFERENCES akaun(kodAkaun),
jumlahMarkah int(10) not null,
jumlahJawabBetul int(10) not null,
jumlahJawabKesalahan int(10) not null,
jumlahMasaGuna time(6) not null,
FOREIGN KEY REFERENCES masa(jumlahMasaGuna),
kodItemDapat int(4),
FOREIGN KEY REFERENCES item(kodItemDapat)
);
您缺少每个 FOREIGN KEY REFERENCES
上的外键。根据需要修改以下内容:
CREATE TABLE markah (
kodKursus int(4),
FOREIGN KEY (foreignKeyToComplete) REFERENCES kursus(kodKursus),
kodAkaun int(4) not null,
FOREIGN KEY (foreignKeyToComplete) REFERENCES akaun(kodAkaun),
jumlahMarkah int(10) not null,
jumlahJawabBetul int(10) not null,
jumlahJawabKesalahan int(10) not null,
jumlahMasaGuna time(6) not null,
FOREIGN KEY (foreignKeyToComplete) REFERENCES masa(jumlahMasaGuna),
kodItemDapat int(4),
FOREIGN KEY (foreignKeyToComplete) REFERENCES item(kodItemDapat)
);