In the case of sub-tables, the data table is cyclically cleared.
Suppose there are tables student0 - student99.
Wouldn’t it be useless to manually clear them?
1. View stored procedures
SHOW PROCEDURE STATUS;
2. Use the stored procedure loop to clear the data table
DROP PROCEDURE if exists truncateTable;
delimiter $$
CREATE PROCEDURE truncateTable()
BEGIN
DECLARE i INT DEFAULT 0;
while i <= 99
do
SET @tablename = CONCAT("student", i);
SET @sqlstring = CONCAT("truncate table ", @tablename);
PREPARE stmt FROM @sqlstring;
EXECUTE stmt;
SET i = i + 1;
END while;
END$$
delimiter ;
CALL truncateTable();
DROP PROCEDURE truncateTable;