当前位置:Gxlcms > mysql > mysql循环存储过程_MySQL

mysql循环存储过程_MySQL

时间:2021-07-01 10:21:17 帮助过:23人阅读

bitsCN.com

mysql循环存储过程

利用存储过程执行一批语句

DELIMITER $$

DROP PROCEDURE IF EXISTS `proc1`$$

CREATE PROCEDURE `proc1`()

BEGIN

declare i integer;

set i=0;

while i<=100 do

begin

set @TABLENAME=CONCAT('update ','sns_userinfo_ext_',i,' set mobile_flag=1,mail_flag=1;');

PREPARE STMT FROM @TABLENAME;

EXECUTE STMT;

SET i=i+1;

end;

end while;

END$$

call ff()

bitsCN.com

人气教程排行