MySQL: Failed to add the foreign key constraint. Missing index for constraint 'xxx_ibfk_1' in the referenced table 'xxx'MySQL: Failed to add the foreign key constraint. Missing index for constraint 'xxx_ibfk_1' in the referenced table 'xxx'MySQL: Failed to add the foreign key constraint. Missing index for constraint 'xxx_ibfk_1' in the referenced table 'xxx'MySQL: Failed to add the foreign key constraint. Missing index for constraint 'xxx_ibfk_1' in the referenced table 'xxx'
  • 首页
  • 博客
  • 文件
  • 书签
  • 分析
  • 登录
Search
Generic filters

MySQL: Failed to add the foreign key constraint. Missing index for constraint 'xxx_ibfk_1' in the referenced table 'xxx'

Published by admin at 2022年7月3日
Categories
  • MySQL
Tags

原因:
关联表的关联属性没有建立索引值。

创建外键约束的要求有以下几点:
-- 1、父表和子表必须使用相同的存储引擎,而且禁止使用临时表
--具有外键列的表称为子表;子表所参照的表称为父表
-- 2、数据表的默认引擎只能为InnoDB
-- 3、外键列和参照列必须具有类似的数据类型。其中数字的长度或是否有符号位必须相同,而字符的长度可以不同
-- 加FOREGIN KEY 关键字的列称为外键列 外键列所参照的列称为参照列
-- 4、外键列和参照列必须建立索引。如果外键列不存在索引的话,MYSQL将自动创建索引。如果参照列不存在索引的话,MySQL不会自动创建索引
-- MySQL会为主键自动创建索引

发表回复 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Categories

  • 猫
  • Python
  • MySQL
  • Django
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • php
  • Practice
  • Virtualization
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • Router
  • Office
  • WordPress
  • SEO
  • English
  • Games
  • Recipes
  • living
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2022 Alaica Blog support@alaica.com