mysql中的外键是什么

本篇内容介绍了“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中的外键是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


当前名称:mysql中的外键是什么
链接分享:http://bzwzjz.com/article/igcsoe.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都企业网站建设公司 成都网站制作 成都网站建设 成都网站设计 成都做网站建设公司 定制网站建设 企业网站设计 阿坝网站设计 网站建设费用 广安网站设计 外贸网站建设 网站制作 达州网站设计 手机网站建设 成都网站设计公司 四川成都网站设计 网站制作公司 营销型网站建设 重庆外贸网站建设 网站制作 成都商城网站制作 手机网站设计