2013-11-25 58 views
0

你好,我有一個問題來創建表。我想創建與「模型」相關的表格SQL和FOREIGN KEY,參考

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; 

模型是帶有標識和名稱的簡單表。 當我點擊運行它,我得到這個錯誤:

#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

我在做什麼錯?

回答

4

你失蹤後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; 
0

逗號你是不是缺少INT後逗號?