MySQL Delete bulk Delete table

Source: Internet
Author: User
Tags mysql delete prepare stmt

BEGIN
declare done int default false;
DECLARE TABLE_NAME_STR VARCHAR (64);
declare table_rows_mum int;
DECLARE sqltext VARCHAR (2000); # Splicing SQL string
DECLARE auto_sql_str VARCHAR (2000);

Declare _cur cursor FOR select table_name,table_rows from Information_schema. ' TABLES ' where table_schema = ' tzgame ' and TA Ble_rows = 0 ORDER BY table_rows Desc; #主订单查询
Declare continue HANDLER for don't found set done = true;
OPEN _cur;
FETCH _cur into Table_name_str,table_rows_mum;
while (not doing) 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 Delete bulk Delete table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.