explicitly specify the column names to be populated in the table
Cause of foreign key issue
Tried loading data using the below command
$ mysql db_test1 -u root < load_dept_manager.dump
Reported Error:
ERROR 1452 (23000) at line 1: Cannot add or update a child row: a foreign key constraint fails (`db_test1`.`dept_manager`, CONSTRAINT `dept_manager_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE)
When opened and viewed the dept_manager the column order were not matching and thus specifying column order explicitly in insert query fixes the problem.
Fix Foreign key issues
Cause of foreign key issue
Tried loading data using the below command
Reported Error:
When opened and viewed the
dept_manager
the column order were not matching and thus specifying column order explicitly in insert query fixes the problem.