Reputation: 47
Hello i have a problem to create table. I would like to create table with refferences to "Model"
CREATE TABLE Marka(
id_marki INT PRIMARY KEY NOT NULL ,
nazwa VARCHAR(40) NOT NULL ,
id_modelu int
FOREIGN KEY(id_modelu) REFERENCES Model(id_modelu) ON DELETE CASCADE
) ENGINE=INNODB;
Model is simple table with id and name. When i clicked to run it i got this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN KEY(id_modelu) REFERENCES Model(id_modelu) ON DELETE CASCADE ) ENGINE=I' at line 5
What am I doing wrong?
Upvotes: 0
Views: 95
Reputation: 204766
You're missing a comma after id_modelu int
CREATE TABLE Marka
(
id_marki INT PRIMARY KEY NOT NULL,
nazwa VARCHAR(40) NOT NULL,
id_modelu int,
FOREIGN KEY(id_modelu) REFERENCES Model(id_modelu) ON DELETE CASCADE
) ENGINE=INNODB;
Upvotes: 4