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

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

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

猜你喜欢

转载自www.cnblogs.com/olzoooo/p/12395669.html