Drop multiple tables in one shot in mysql

Krunal picture Krunal · Feb 7, 2011 · Viewed 128.9k times · Source

How to drop multiple tables from one single database at one command. something like,

> use test; 
> drop table a,b,c;

where a,b,c are the tables from database test.

Answer

Leniel Maccaferri picture Leniel Maccaferri · Feb 7, 2011

Example:

Let's say table A has two children B and C. Then we can use the following syntax to drop all tables.

DROP TABLE IF EXISTS B,C,A;

This can be placed in the beginning of the script instead of individually dropping each table.