批量删除数据库中所有的表和表中的数据

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

通过在information_schema中查询出数据库名为mytestdb下的所有表然后进行删表语句拼接,之后再执行查询并拼接好的所有的删表语句就行了。

posted @ 2020-03-02 14:56  olzoooo  阅读(883)  评论(0编辑  收藏  举报