2016-10-12 42 views
0
Create Table Items 
(i_num Integer Not Null Primary Key, 
i_title Varchar (50) Not Null, 
d_num Integer Not Null, 
i_price Decimal (6,2) Not Null, 
i_release_date Date Not Null, 
i_genre Varchar (15) Not Null Check 
(i_genre IN ('Jazz', 'Blues', 'Country', 'Rock', 'Alternative', 'Rap', 'Classical', 'Other')), 
Foreign Key (d_num) References Distributors (d_num), 
On Update Cascade 
On Delete Cascade); 
+1

你的問題是什麼? –

+0

問題是爲什麼我得到我的代碼錯誤。 –

+0

請顯示實際的錯誤信息,而不僅僅是錯誤號。 –

回答

0
Create Table Distributors (
    d_num Integer Not null 
); 

Create Table Items(
i_num Integer Not Null Primary Key, 
i_title Varchar(50) Not Null, 
d_num Integer Not Null, 
i_price Decimal(6,2) Not Null, 
i_release_date Date Not Null, 
i_genre Varchar(15) Not Null, 
constraint FOREIGN KEY (d_num) REFERENCES Distributors(d_num) ON UPDATE CASCADE ON DELETE CASCADE, 
Constraint ´genre_items_in´ Check (i_genre IN ('Jazz', 'Blues', 'Country', 'Rock', 'Alternative', 'Rap', 'Classical', 'Other')) 
); 

查明錯誤試試這個,當定義級聯你在利用unncessary「」在你的命令符號。

+0

謝謝,那也沒用。 –

+0

您能否給我提供錯誤的詳細信息。 –

+0

你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊,在' Constraint'genre_items_in'檢查(i_genre IN('Jazz','Blues','Country',''at line 8 –

相關問題