首先建立user表,如下图

然后建立message表,userid用作外键,关联user表的id

点击上面的外键按钮,添加外键如下

结果保存时报错: cannot add foreign key constraint

最后查找发现user表中的id和message表中的userid定义的属性不一样,如下,一个选择了无符号,一个没选,两个选一样的,按照上面添加外键的方法就解决问题了:

Navicat MYSQL 建立关联表 保存时遇到 cannot add foreign key constraint的更多相关文章

  1. mysql执行带外键的sql文件时出现mysql ERROR 1215 (HY000): Cannot add foreign key constraint的解决

    ERROR 1215 (HY000): Cannot add foreign key constraint 最近在建表时遇到了这个错误,然后找了下找到了解决办法,记录下: 本来是要建两张表: 1 2 ...

  2. MySQL添加外键时报错 ERROR 1215 (HY000): Cannot add foreign key constraint

    1.数据类型      2.数据表的引擎 数据表 mysql> show tables; +------------------+ | Tables_in_market | +--------- ...

  3. 由于外键的存在引发的一个mysql问题 Cannot change column 'id': used in a foreign key constraint

    Duplicate entry ' for key 'PRIMARY' 一查,发现表没有设置自增长. 尝试增加修改表,添加自增长. ALTER TABLE sh_incentive_item MODI ...

  4. Navicat For MySQL--外键建立与cannot add foreign key constraint分析

    hrm_job.png 参考资料: https://blog.csdn.net/ytm15732625529/article/details/53729155 https://www.cnblogs. ...

  5. MYSQL: Cannot delete or update a parent row: a foreign key constraint fails

    这可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据.可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. SET FOREIGN_KEY_CHE ...

  6. MySQL Error 1215: Cannot add foreign key constraint

    MySQL Error 1215: Cannot add foreign key constraint DROP TABLE IF EXISTS `r_role_region`; CREATE TAB ...

  7. 数据库建表的时候报 “1215 Cannot add foreign key constraint”

    很大原因是因为: 引用表中的字段类型和被引用的主键的类型不统一. 比如说学生表中有一个班级ID字段引用班级表. 班级表的ID是int类型,学生表中的班级ID是Varchar类型. 肯定会提示上述121 ...

  8. MySQL添加foreign key时出现1215 Cannot add the foreign key constraint

    引言: MySQL中经常会需要创建父子表之间的约束,这个约束是需要建立在主外键基础之上的,这里解决了一个在创建主外键约束过程中碰到的一个问题. mysql中添加外键约束遇到一下情况: cannot a ...

  9. Mysql - 删除表时出现: Cannot delete or update a parent row: a foreign key constraint fails

    现象 MySQL在删除一张表时出现 ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint ...

随机推荐

  1. element-ui Rate组件源码分析整理笔记(十三)

    Rate组件源码比较简单,有添加部分注释 main.vue <template> <!--valuenow当前的评分 valuetext当前显示的文本--> <div c ...

  2. block注意事项

    1.block的声明和注意事项 #import "ZYViewController.h" @interface ZYViewController () @end /*用typede ...

  3. 苹果审核之遇到IPV6问题被拒的解决方法

    情景: 等待苹果审核上线时,发现因为IPV6被拒了.这是悲剧,以下是苹果审核给我的理由: We discovered one or more bugs on Wi-Fi connected to an ...

  4. 还学不会webpack?看这篇!

    摘要: webpack入门教程. 原文:还学不会webpack?看这篇! 作者:MudOnTire Fundebug经授权转载,版权归原作者所有. Webpack已经流行好久了,但很多同学使用webp ...

  5. ulimit 更改 gcc升级 查看显卡状态命令

    一.更改ulimit: vim /etc/security/limits.conf 在文件最下方添加以下内容 * soft nofile 65536* hard nofile 65536 二. gcc ...

  6. 进化后的const分析

    C语言中的const const修饰的变量是只读的,本质还是变量 const修饰的局部变量在栈上分配空间 const修饰的全局变量在只读存储区分配空间 const只在编译期有用,在运行期无用 注意:c ...

  7. echo和printf打印输出

    [root@node2 scprits]# echo Hello World! Hello World! [root@node2 scprits]# echo 'Hello World!' Hello ...

  8. nullptr与NULL

    NULL NULL can be defined as any null pointer constant. Thus existing code can retain definitions of  ...

  9. SLAM:暑期学校

    专门开个(大)坑: RGB-D SLAM:姜翰青,商汤 视觉SLAM:章国锋,浙大CAD&CG国家重点实验室

  10. luoguP3704 [SDOI2017]数字表格

    题意 默认\(n\leqslant m\) 所求即为:\(\prod\limits_{i=1}^n\prod\limits_{j=1}^mf[\gcd(i,j)]\) 枚举\(\gcd(i,j)\)变 ...