加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 运营中心 > 搜索优化 > 正文

mysql中的外键是啥

发布时间:2022-02-12 10:17:17 所属栏目:搜索优化 来源:互联网
导读:本篇内容介绍了mysql中的外键是什么的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! Foreign keys definitions are subject to the following condi
      本篇内容介绍了“mysql中的外键是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
 
Foreign keys definitions are subject to the following conditions:
 
Both tables must be InnoDB tables and they must not be TEMPORARY tables.
Corresponding columns in the foreign key and the referenced key must have similar internal data types inside InnoDB so that they can be compared without a type conversion. The size and sign of integer types must be the same. The length of string types need not be the same. For non-binary (character) string columns, the character set and collation must be the same.
In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Such an index is created on the referencing table automatically if it does not exist.
In the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order.
Index prefixes on foreign key columns are not supported. One consequence of this is that BLOB and TEXT columns cannot be included in a foreign key, because indexes on those columns must always include a prefix length.
If the CONSTRAINT symbol clause is given, the symbol value must be unique in the database. If the clause is not given, InnoDB creates the name automatically.
参照mysql中的说明,建外键时一定要注意2个表字段之间的关系,一定要一致,mysql中的数据类型相对要比oracle的多,我遇到了int ,unsigned的问题。1个表的id字段是int,令1个表的id字段是int,unsigned。结果建了很多次外键,都没成功,找了半天才看到。看来还是太粗心。。
 
“mysql中的外键是什么”的内容就介绍到这里了,感谢大家的阅读。

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读