MySQL error cannot add foreign key constraint

后端 未结 6 1627
既然无缘
既然无缘 2021-01-14 01:52

what is wrong?

mysql> create table price(
    -> p_code char(1) not null,
    -> p_description varchar(20),
    -> p_rentfee decimal(2,2) not nul         


        
6条回答
  •  -上瘾入骨i
    2021-01-14 02:34

    p_code should be a primary key in your price table:

    create table price(
    -> p_code char(1) not null,
    -> p_description varchar(20),
    -> p_rentfee decimal(2,2) not null,
    -> p_dylatefee decimal(2,2),
    -> PRIMARY KEY ( p_code ));
    

提交回复
热议问题