DROP ALL TABLES в MySQL

The heading at this note is a bit wrong. In MySQL there is no such command, and it would be desirable, that it was. Sometimes there are problems in which we want to remove all tables of a DB, but not her (that there were its parametres, such as access rights, codings, etc.). To solve such problem it is possible with the help command:

a=name;b=pass;c=base;mysqldump -u$a -p$b --add-drop-table --no-data $c|grep ^DROP|mysql -u$a -p$b $c

The first command of the conveyor we create «dump» the databases, consisting of every possible DROP TABLE, but without the data. The second command we choose only the lines beginning with DROP, and at last, we fill in the received commands in MySQL.

Scroll to top