SQL syntax error 1060 42000 Foreign keys, primary key error

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

SQL syntax error 1060 42000 Foreign keys, primary key error

Postby DariusCG » 13. September 2019 12:26

I have started learning MariaDB and have task to make 4 tables. I have created 3 tables easily, but now I have to create last table Uzsakymai. The table should contain the fields: Uzsakovo_kodas, Leidinio_kodas, Uzsakymo_periodas.

The first foreign key will connect Uzsakymai and Uzsakovai, the second key will connect the tables Uzsakymai and Periodiniai_lediniai

So I type like this:

CREATE TABLE Uzsakymai(
Uzsakovo_kodas INT(11),
Leidinio_kodas INT, Uzsakymo_periodas_menesiai int,
Primary key(Uzsakovo_kodas)
Foreign KEY(Uzsakovo_kodas) REFERENCES Uzsakymai(Uzsakovo_kodas));
But I am gotting syntax error. Could somebody telm what syntax erorro is here?

ERROR 1064 (42000): 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 'PRIMARY KEY(Uzsakovo_kodas) FOREIGN KEY(Uzsakovo_kodas) References Uzsakovai(Uzs' at line 1
DariusCG
 
Posts: 2
Joined: 13. September 2019 12:23
XAMPP version: 7.3.9
Operating System: Winodws 10

Re: SQL syntax error 1060 42000 Foreign keys, primary key er

Postby JJ_Tagy » 15. September 2019 17:18

JJ_Tagy
 
Posts: 764
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 3 guests