Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:59:01+00:00 2026-05-27T02:59:01+00:00

Is there a nice easy way to drop all tables from a MySQL database,

  • 0

Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:59:02+00:00Added an answer on May 27, 2026 at 2:59 am

    I found the generated set of drop statements useful, and recommend these tweaks:

    1. Limit the generated drops to your database like this:
    SELECT concat('DROP TABLE IF EXISTS `', table_name, '`;')
    FROM information_schema.tables
    WHERE table_schema = 'MyDatabaseName';
    

    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 to DROP VIEW `VIEW_NAME` manually.

    1. Note, per http://dev.mysql.com/doc/refman/5.5/en/drop-table.html, dropping with cascade is pointless / misleading:

    “RESTRICT and CASCADE are permitted to make porting easier. In MySQL 5.5, they do nothing.”

    Therefore, in order for the drop statements to work if you need:

    SET FOREIGN_KEY_CHECKS = 0
    

    This will disable referential integrity checks – so when you are done performing the drops you need, you will want to reset key checking with

    SET FOREIGN_KEY_CHECKS = 1
    
    1. The final execution should look like:
    SET FOREIGN_KEY_CHECKS = 0;
    -- Your semicolon separated list of DROP statements here
    SET FOREIGN_KEY_CHECKS = 1;
    

    NB: to use output of SELECT easier, mysql -B option can help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The SWT-Gui looks very nice. Is there an easy way to use it in
Is there a nice and easy way to have a Colorbox act as a
Is there an easy way to get any more control over the py2app traceback
Is there an easy way to select either a file OR a folder from
Is there any easy way to exchange the position of 2 elements - or
Is there a nice and easy way to convert a Java Date into XML
Is there a nice way to split a collection into n parts with LINQ?
Is there a nice way in the WinAPI to get a path relative to
Are there any nice libraries to render text in an image for Java? Java
Hi are there any nice videos on how to use exceptions in Delphi.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.