首页 > 代码库 > Mysql错误问题:ERROR 1005 (HY000): Can't create table 'crm_1.tbl_client' (errno: 150)

Mysql错误问题:ERROR 1005 (HY000): Can't create table 'crm_1.tbl_client' (errno: 150)

MySQL外键创建条件:

1.两个表必须是InnoDB数据引擎
2.外键表的外键字段必须是主键
3.字段类型必须一致

创建表时创建外键:

 create table tbl_client(userName varchar(255) not null, address varchar(255), createDate timestamp not null default now(), createUserName varchar(255), foreign key(createUserName) references tbl_user(userName));

Mysql错误问题:ERROR 1005 (HY000): Can't create table 'crm_1.tbl_client' (errno: 150)