我正在创建表并设置约束。我已遵循以下建议MySQL Creating tables with Foreign Keys giving errno: 150 我的查询如下
CREATE TABLE `lng02_rpt_b_calvedets_msel_whydead` (
`hh_id` varchar(10) NOT NULL COMMENT 'Farmer',
`rpt_b_calvedets_rowid` int(3) NOT NULL COMMENT 'Unique Row ID',
`whydead` int(3) NOT NULL COMMENT 'What was the cause of death/abortion',
`rowuuid` varchar(80) DEFAULT NULL COMMENT 'Unique Row Identifier (UUID)',
`damid` varchar(150) DEFAULT NULL,
`calvdatealv` date DEFAULT NULL,
PRIMARY KEY (`hh_id`,`rpt_b_calvedets_rowid`,`whydead`),
KEY `lng02_fk29_lng02_rpt_b_calvedets_msel_whydead_lkpwhydead` (`whydead`),
KEY `lng02_fk30L_lng02_rpt_b_calvedets_msel_whydead_rpt_b_calvedets` (`hh_id`),
CONSTRAINT `lng02_fk29_lng02_rpt_b_calvedets_msel_whydead_lkpwhydead` FOREIGN KEY (`whydead`) REFERENCES `lng02_lkpwhydead` (`whydead_cod`) ON UPDATE NO ACTION,
CONSTRAINT `lng02_fk30L_lng02_rpt_b_calvedets_msel_whydead_rpt_b_calvedets` FOREIGN KEY (`hh_id`) REFERENCES `lng02_rpt_b_calvedets` (`hh_id`) ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
我收到以下错误
Error Code: 1005. Can't create table `adggeth`.`lng02_rpt_b_calvedets_msel_whydead` (errno: 150 "Foreign key constraint is incorrectly formed") 0.0058 sec