Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL 1表中的多个级联外键_Mysql_Foreign Keys - Fatal编程技术网

MySQL 1表中的多个级联外键

MySQL 1表中的多个级联外键,mysql,foreign-keys,Mysql,Foreign Keys,我使用MySQL 5.1。有一个包含两个外键的表,引用两个不同的表: CREATE TABLE `words` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `word` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `words_groups` ( `id` int(10) u

我使用MySQL 5.1。有一个包含两个外键的表,引用两个不同的表:

CREATE TABLE `words` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `word` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `words_groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `words_in_group` (
  `group_id` int(10) unsigned DEFAULT NULL,
  `word_id` int(10) unsigned DEFAULT NULL,
  KEY `word_id` (`word_id`) USING BTREE,
  KEY `group_id` (`group_id`) USING BTREE,
  CONSTRAINT `group_id` FOREIGN KEY (`group_id`) REFERENCES `words_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `word_id_fk` FOREIGN KEY (`word_id`) REFERENCES `words` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
但由于某种原因,当我使用phpMyAdmin或Navicat并检查此表结构时,组表中words_中的一个键的CASCADE属性未设置


可能是什么?如何解决?也许可以使用触发器?

通过插入一些测试数据,然后从单词中删除一行来测试级联

您还可以使用mysqldump转储数据库,并读取数据库服务器认为它应该执行的操作


我敢肯定,您会发现级联按书面形式工作,而不是按图形界面所示。

问题:为什么要对引用自动递增键的外键进行更新级联?似乎主键永远不应该更新,所以为什么要级联?=为什么要在更新时级联=
你是对的。我只需要删除级联。
这是MySQL中的一个错误。在我从5.1升级到5.5之后,多个级联键变得可用。