通过创建mysql函数,批量生成测试数据:下面是一个Demo
BEGIN
declare i int default 0;
declare userId long DEFAULT 10100;
declare toUserId long DEFAULT 10100;
declare stateflag int DEFAULT 0;
declare numFlag int DEFAULT 0;
start transaction; #定义事务
while i<1000000 do
set numFlag = numFlag +1;
if numFlag > 200 then set numFlag = 0; set userId = userId - 1; else set toUserId = toUserId - 1; end if;
if toUserId < 0 then set toUserId = 10100 - 100; end if ;
if stateflag > 0 then set stateflag = 0; else set stateflag = 1 ; end if;
insert into tbl_user_attention(user_id,to_user_id,is_delete,is_mutually,create_time,update_time)
VALUES(userId,toUserId,stateflag,stateflag,now(),now());
set i=i+1;
end while;
commit; #开始执行事务
END