mysql存储过程示例:
USE 数据库名称;
DROP PROCEDURE IF EXISTS 数据库名称.存储过程名称;
delimiter $$
CREATE PROCEDURE 数据库名称.存储过程名称(in v_count bigint)
BEGIN
set @vi=1;
set @vcount=v_count;
select ceil(round(count(0)/@vcount,2)) into @vnum from 字段1;
while(@vi<=@vcount)
do
if @vi=100 then
update 字段1 set tid=@vi where vid>=(@vi*@vnum);
else
update 字段1 set tid=@vi where vid>=((@vi-1)*@vnum) and vid
end if;
COMMIT;
set @vi=@vi+1;
END WHILE;
end $$
delete from 表1 where id>@vcount;
delete from 表2 where id>@vcount*100;
delimiter ;
call 数据库名称.存储过程名称(100);