Skip to content
Advertisement

Drop multiple tables in one shot in mysql

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement