CREATE PROCEDURE `up_truncate_all_table`() BEGIN DECLARE done INT DEFAULT 0; DECLARE tname CHAR(50); DECLARE cur1 CURSOR FOR SELECT table_name from INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name'; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; REPEAT FETCH cur1 INTO tname; IF NOT done THEN set @str=concat('truncate table ', tname); prepare stmt1 from @str; execute stmt1; deallocate prepare stmt1; END IF; UNTIL done END REPEAT; CLOSE cur1; END