create table t_sells(
-> selid int primary key comment '销售编号',
-> proid int comment '商品编号',
-> seldate datetime not null comment '销售日期',
-> selcount int not null comment '销售数量',
-> selprice int not null comment '销售价格',
-> cusid int comment '客户编号',
-> constraint fk_8 foreign key(proid) references t_product(proid),
-> constraint fk_9 foreign key(cusid) references t_customer(cusid)
-> );
1005 - Can't create table 'homework.t_sells' (errno: 150)
在mysql 中建立引用约束的时候会出现MySQL ERROR 1005: Can’t create table (errno: 150)的错误信息,结果是不能建立引用约束。
出现问题的大致情况
1、外键的引用类型不一样,如主键是int外键是char
2、找不到主表中引用的列
3、引用的字段和外键的字符编码不一致,也可能存储引擎不一样
4、引用的字段和外键的约束不同
我的错误是:相关联的表的名字t_customer与已建的表名不一致。