The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

SQL Foreign Constraint – Part II -Cannot drop table ‘customers’ referenced by a foreign key constraint

SQL Foreign Constraint – Part II -Cannot drop table ‘customers’ referenced by a foreign key constraint

Super Learner
0
Votes
1
Answer

07:30:12 Drop table customers Error Code: 3730. Cannot drop table ‘customers’ referenced by a foreign key constraint ‘constraint_1’ on table ‘sales’. 0.000 sec
 
How do I get around this issue?

1 Answer

365 Team
0
Votes

Hi Babatunde!
Thanks for reaching out.
Most probably, you are having values in a table that is a child table to the customers table, that are still in use. So, MySQL disallows/prevents the customers table from being dropped namely because of this foreign key constraint.
To solve the problem, you should delete the relevant piece of data from the child table that prevents you from dropping customers (which is, obviously, the parent one).
Hope this helps.
Best,
Martin