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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。