ITPub博客

首页 > 数据库 > MySQL > MySQL 创建外键报错Can't write; duplicate key in table

MySQL 创建外键报错Can't write; duplicate key in table

原创 MySQL 作者:feelpurple 时间:2017-09-03 20:29:42 0 删除 编辑
mysql> create table orders2(id int auto_increment primary key, customer_id int, description varchar(50), constraint fk_orders foreign key (customer_id) references customer(id));
ERROR 1105 (HY000): Can't write; duplicate key in table 'orders2'

报错原因:
外键名称已经存在,更换一个外键名称
mysql> create table orders2(id int auto_increment primary key, customer_id int, description varchar(50), constraint fk_orders2 foreign key (customer_id) references customer2(id));
Query OK, 0 rows affected (0.22 sec)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26506993/viewspace-2144449/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-08-01

  • 博文量
    404
  • 访问量
    1673938