MySQL游标循环示例
如果用in语句,感觉很慢,跑了好久都没有结果,用存储过程删除可以把握进度,这个是MySQL游标循环的示例代码,避免以后经常找,记录上来。
CREATE DEFINER=`root`@`%` PROCEDURE `bi`.`clean_data`()
READS SQL DATA
BEGIN
declare v_imei varchar(128);
declare stop int default 0;
declare cur cursor for (select imei from bi.tmp_imei);
declare CONTINUE HANDLER FOR SQLSTATE '02000' SET stop=1;
OPEN cur;
FETCH cur INTO v_imei;
WHILE stop <> 1 DO
delete from bi.tmp_dt_fee_user_info where imei=v_imei;
FETCH cur INTO v_imei;
END WHILE;
CLOSE cur;
END
相关推荐
zycchun 2020-10-16
liuyang000 2020-09-25
talkingDB 2020-06-12
LuoXinLoves 2020-06-06
Justdoit00 2020-04-26
lt云飞扬gt 2020-04-25
流云追风 2020-04-22
lt云飞扬gt 2020-04-21
yuanshuai 2020-03-06
dreamhua 2020-02-21
ALiDan 2020-02-18
dreamhua 2020-01-31
whyname 2019-12-29
tanrong 2019-12-17
暗夜之城 2019-11-13
liuyang000 2019-11-01
dreamhua 2019-10-28
廖金龙 2016-01-04