MySql清空所有表数据【慎用】
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
申明
非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!
博文欢迎转载,但请给出原文连接。