technical skills grow

Responsive Ads Here

Thursday, January 7, 2021

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails

 16:17:41    alter table company_station_mapping add constraint FK_COMPANY_STATION_MAPPING_15  FOREIGN KEY  (COMPANY_ID)   REFERENCES `COMPANY` (`COMPANY_ID`)    

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`aws_mh`.`#sql-875_479e81`, CONSTRAINT `FK_COMPANY_STATION_MAPPING_15` FOREIGN KEY (`COMPANY_ID`) REFERENCES `company` (`COMPANY_ID`))    0.052 sec

Check foreign key constraint is enable or not if it is enable  
SELECT @@GLOBAL.foreign_key_checks, @@SESSION.foreign_key_checks;

You have to stop foreign_key constraint
SET foreign_key_checks = 0;

alter table company_station_mapping add constraint FK_COMPANY_STATION_MAPPING_5  FOREIGN KEY  (COMPANY_ID)
REFERENCES `COMPANY` (`COMPANY_ID`)

After set foreign_key constraint again enable
SET foreign_key_checks = 1;



 

No comments:

Post a Comment

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts