我试图执行以下SQL并收到errno:150'无法创建表path_relations'作为响应。根据MySQL文档,这是由我的FOREIGN KEY约束引起的问题。我究竟做错了什么?将FOREIGN KEY表添加到MySQL数据库导致errno 150
DROP TABLE IF EXISTS `paths`;
DROP TABLE IF EXISTS `path_relations`;
CREATE TABLE `paths` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(256) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `path_relations` (
`ancestor` int(11) NOT NULL DEFAULT '0',
`descendant` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY(`ancestor`, `descendant`),
FOREIGN KEY(`ancestor`) REFERENCES paths(`id`),
FOREIGN KEY(`descendant`) REFERENCES paths(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2应该是平等的,他们不是现在,固定无符号的一种方式或其他将帮助 – Nanne 2012-07-10 13:51:00