我在mysql中用一些外键创建表时出错,下面是我的脚本:
CREATE TABLE tbl_mt_kuliah (
KD_AUTO INT (4) NOT NULL AUTO_INCREMENT,
NIM INT (10) NOT NULL,
KD_MATA_KULIAH INT (4) NOT NULL,
RUANG VARCHAR (4) NOT NULL,
KD_DOSEN INT (4) NOT NULL,
JAM TIME NOT NULL,
HARI DATE NOT NULL,
TH_AJARAN YEAR NOT NULL,
SMESTER INT (2) NOT NULL,
PRIMARY KEY KD_AUTO,
FOREIGN KEY FK_MATKUL(KD_MATA_KULIAH) REFERENCES mt_kuliah (KD_MATA_KULIAH),
FOREIGN KEY FK_MHS(NIM) REFERENCES tbl_mahasiswa (NIM),
FOREIGN KEY FK_DOSEN(KD_DOSEN) REFERENCES tbl_dosen (KD_DOSEN)
);
下面是错误:
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to
your MariaDB server version for the right syntax to use near '
foreign KEY FK_MATKUL(KD_MATA_KULIAH) references mt_kuliah (KD_MATA_KULIAH),
' at line 12
1条答案
按热度按时间pbossiut1#
我想这对你有帮助。