Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I found the generated set of drop statements useful, and recommend these tweaks:
Note 1: This does not execute the DROP statements, it just gives you a list of them. You will need to cut and paste the output into your SQL engine to execute them.
Note 2: If you have VIEWs, you’ll have to correct each
DROP TABLE `VIEW_NAME`statement toDROP VIEW `VIEW_NAME`manually.Therefore, in order for the drop statements to work if you need:
This will disable referential integrity checks – so when you are done performing the drops you need, you will want to reset key checking with
NB: to use output of SELECT easier, mysql -B option can help.