外键约束更新的MySQL错误

时间:2018-11-16 16:05:40

标签: mysql

我正尝试向表中添加一个约束,如下所示

 SET FOREIGN_KEY_CHECKS=0;ALTER TABLE lng02_rpt_b_calvedets 
ADD CONSTRAINT fklng02_lng02_rpt_b_calvedets FOREIGN KEY (hh_id,visitdate) REFERENCES lng01_maininfo(hh_id,visitdate);
SET FOREIGN_KEY_CHECKS=1;

我收到如下错误

 Error Code: 1822. Failed to add the foreign key constaint. Missing index for constraint 'fklng02_lng02_rpt_b_calvedets' in the referenced table 'lng01_maininfo'   0.0027 sec

0 个答案:

没有答案