[Mysql]---Navicat --外键建立与cannot add foreign key constraint分析
来源:互联网 发布:json怎么写注释 编辑:程序博客网 时间:2024/06/02 01:13
用Navicat为MySQL数据库的两个表之间建立外键关系,出现“cannot add foreign key constraint”错误.
设计外键的界面,有七列:名(name):可以不填,保存时会自动生成。栏位(FieldName):要设置的外键,如:t_stuschoolregisterinfo 里的IDCard参考数据库(Reference DataBase):外键关联的数据库被参考表(Reference Table):关联的表,这里是t_stupersoninfo表参考栏位(Forgin filed Names):关联的字段,t_stupersoninfo里的IDCard删除时(ondelete):删除时候的动作,当时我选择的是SETNULL更新时(onupdate):更新时候的动作,我选择的是CASCADE以上字段也可以按照自己的需求填写,设置完成后保存即可。
创建外键失败:
创建外键的前提:
- 参照表的字段是否存在.
- 组成外键字段要求被索引,外键字段在其他表上是主键.
- 都为innodb表.
- 字段类型一样.
- 语法正确.
当我们创建外键时,外键的索引会自动建起来,这里类型要一样很重要,除了上面的,下方Unsigned也要注意 是否和原表中一样
0 0
- 【mysql】---Navicat --外键建立与cannot add foreign key constraint分析
- [Mysql]---Navicat --外键建立与cannot add foreign key constraint分析
- mysql : cannot add foreign key constraint
- mysql无法添加外键约束(cannot add foreign key constraint)
- MySQL中创建外键的错误:1215 Cannot add the foreign key constraint
- mysql无法添加外键约束(cannot add foreign key constraint)
- mysql中添加外键约束失败(cannot add foreign key constraint)
- MySQL 不能添加外键:Cannot add foreign key constraint错误
- MySQL 1215 Cannot add foreign key constraint 错误解决办法
- Mysql学习之cannot add foreign key constraint
- mysql出现Cannot add foreign key constraint原因
- Mysql出现 Cannot add foreign key constraint 错误
- Liquibase异常 mysql数据库 Cannot add foreign key constraint
- 1215-Cannot add foreign key constraint
- migration cannot add foreign key constraint
- 1215 - Cannot add foreign key constraint
- 1215 - Cannot add foreign key constraint
- 1215 Cannot add the foreign key constraint
- [JZOJ5081]. 【GDSOI2017第三轮模拟】Travel Plan
- Android 对非 Google Play 设备上运行的应用启用后台调度
- Maven启用代理访问(二)
- 14 关于单片机死机的一些问题
- 4-9 统计个位数字 (15分)
- [Mysql]---Navicat --外键建立与cannot add foreign key constraint分析
- Java中的IO流
- Maven本地资源库(三)
- idea插件报错导致不能启动的处理技巧
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad (二进制枚举)
- AJAX长轮询不工作与IE浏览器(AJAX long polling not working with IE)
- 事务的四大隔离级别
- android:gravity 和 android:layout_Gravity属性
- Flask and PostgreSQL on Heroku