mysql 删除批量删除表
Posted 陈可
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 删除批量删除表相关的知识,希望对你有一定的参考价值。
BEGIN
declare done int default false;
declare table_name_str VARCHAR(64);
declare table_rows_mum int;
DECLARE sqltext VARCHAR(2000); # 拼接sql串
DECLARE auto_sql_str VARCHAR(2000);
declare _Cur cursor for select table_name,table_rows from information_schema.`TABLES` where TABLE_SCHEMA = ‘tzgame‘ and table_rows = 0 order by table_rows desc ;#主订单查询
declare continue HANDLER for not found set done = true;
OPEN _Cur;
FETCH _Cur INTO table_name_str,table_rows_mum;
while(not done) do
set sqltext:= CONCAT(‘TRUNCATE ‘, table_name_str,‘;‘);
set auto_sql_str:= CONCAT(‘ ALTER TABLE ‘, table_name_str, ‘ AUTO_INCREMENT = 1; ‘);
PREPARE STMT FROM sqltext;
EXECUTE STMT;
PREPARE STMT FROM auto_sql_str;
EXECUTE STMT;
fetch _Cur into table_name_str,table_rows_mum;
end while;
CLOSE _Cur;
end
以上是关于mysql 删除批量删除表的主要内容,如果未能解决你的问题,请参考以下文章
mysql批量删除,已经获得id,条件是另一个表,不存在的就删除,请问sql语句怎么写?
mysql 怎么批量删除没有数据的数据?怎么重新随即排列主键?