datacharmer / test_db

A sample MySQL database with an integrated test suite, used to test your applications and database servers
4.06k stars 2.59k forks source link

fix the foreign key issue in `load_dept_manager.dump` data load #2

Closed samundra closed 8 years ago

samundra commented 8 years ago

Fix Foreign key issues

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.