nvsky

 

日常开发或服务器部署时,我们可能会遇到需要清空表或表数据的情况,下面语法执行结果即为清除语句,将结果复制到查询中执行即可。

table_schema=\'数据库名\';

1、清空test库中表数据:

select concat(\'truncate table \',table_schema,\'.\',table_name,\';\') as \'执行sql\' from information_schema.TABLES where table_schema=\'test\';

2、删除test库中所有表:

select concat(\'drop table \',table_schema,\'.\',table_name,\';\') as \'执行sql\' from information_schema.TABLES where table_schema=\'test\';

 

分类:

技术点:

相关文章: