MySQL中循环插入数据

2020-09-07 08:48:00
六月
来源:
https://www.csdn.net/gather_2a/MtTaMgxsMTUxNi1ibG9n.html
转贴 781

通过while语句实现循环插入数据

BEGIN

DECLARE a INT DEFAULT 1;

WHILE (a <= 1000) DO

INSERT INTO equipment_log (equipment_id, x_vibrate, y_vibrate, z_vibrate, front_bearing_temp,  back_bearing_temp, power, flow, radial_signal, axial_signal, current, stator_cavity_pressure, winding_temp, turn, fwd, rev, u_ele, v_ele, w_ele, pick_time) VALUES (1, '测试1', '测试1', '测试1', rand_num(1, 9), rand_num(1, 9), rand_num(1, 9), rand_num(1, 9), rand_num(1, 900), rand_num(1, 1200), rand_num(1, 9), rand_num(1, 9), rand_num(1, 9), rand_num(1, 9), 0, 1, 0, 0, 0, SUBDATE(now(),interval 10*a minute));

SET a = a + 1;

END WHILE;


END

参考: https://blog.csdn.net/Bulter1996/article/details/91911136

    https://www.imooc.com/wenda/detail/602985

    https://www.jianshu.com/u/1580f0ebb59c

发表评论
评论通过审核后显示。