为什么我的代码出现错误1064?我检查了堆栈溢出,但我无法用代码查明错误

时间:2016-10-12 05:18:32

标签: mysql

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)

    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'))
);

试试这个,在定义级联时,你在命令中使用了不必要的“,”符号。