Logo Background

MySQL Drop Table Command

  • Instead of running the drop table command one by one in MySQL Database, use the script below to generate the long list of drop table command.

    mysql -u <username> -p <db name> -e "show tables" | grep -v Tables_in | 
    grep -v "+" | \gawk '{print "drop table " $1 ";"}'

    This command won’t drop any table in your MySQL database, but I advise you to run this in your TEST or DEV environment unless you know what is this command doing. In actual, this command will generate the drop table list of of the table resides in your MySQL database.

Leave a Comment