标签:保存数据 close 存储过程 dea format 动态 表数据 sql语句 游标
BEGIN
DECLARE strClear VARCHAR(256);
DECLARE done INT DEFAULT 0;
#定义游标
DECLARE curOne CURSOR FOR select concat(‘truncate table ‘,table_name,‘;‘) from information_schema.TABLES where table_schema=‘test‘;
#绑定控制变量到游标,游标循环结束自动转为True
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
#打开游标
OPEN curOne;
REPEAT
FETCH curOne INTO strClear;
#SELECT strClear;
#动态执行SQL语句
SET @mysql = strClear;
PREPARE stmt from @mysql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
UNTIL done = 1 END REPEAT;
#关闭游标
CLOSE curOne;
END
标签:保存数据 close 存储过程 dea format 动态 表数据 sql语句 游标
原文地址:https://www.cnblogs.com/lovemj/p/9209228.html