Home i got error when creating table with some foreign key in MySQL
Reply: 0

i got error when creating table with some foreign key in MySQL

user924
1#
user924 Published in July 16, 2018, 8:35 pm

i got error when creating table with some foreign key in MySQL, here is my script :

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)

);

and here is the error :

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
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313672 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO