首页 > 数据库技术 > 详细

关于MySQL:ERROR 1022 (23000): Can't write; duplicate key in table 'test4'

时间:2015-08-30 06:26:58      阅读:4705      评论:0      收藏:0      [点我收藏+]

ERROR 1022 (23000): Can‘t write; duplicate key in table ‘test4‘:在为"test4"表设置外键时.外键名与已有的外键名重复;代码如下,注意加粗部分

 

错误代码:

mysql> create table test4(

    -> id int,

    -> cp_name varchar(32),

    -> constraint test_fk foreign key(cp_name) references student(name)

    -> );

ERROR 1022 (23000): Can‘t write; duplicate key in table ‘test4‘

 

正确代码:

mysql> create table test4(

    -> id int,

    -> cp_name varchar(32),

    -> constraint test1_fk foreign key(cp_name) references student(name)

    -> );

Query OK, 0 rows affected (0.54 sec)

 

关于MySQL:ERROR 1022 (23000): Can't write; duplicate key in table 'test4'

原文:http://www.cnblogs.com/javk/p/4770217.html

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!