Drop a list of MySQL tables using schema meta-data


You can select tables you would like to drop from MySQL's meta schema. In this case I want to drop all tables of the user/schema user.

select concat('drop table ', table_name, ';') from information_schema.tables where table_schema = 'user';

Provides following output:
'drop table booking;'
'drop table bookings;'
'drop table languages;'
'drop table report;'
'drop table reports;'
'drop table resource;'
'drop table resource_languages;'
'drop table resources;'
'drop table resources_languages;'
'drop table session;'
'drop table sessions;'
'drop table slot;'
'drop table slots;'
'drop table user;'

Comments

Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

NetBeans 6.1: Working with Google´s Android SDK, Groovy and Grails