DELIMITER // create PROCEDURE insert_logs_test(in loop_times INT) BEGIN DECLARE var INT DEFAULT 0; DECLARE l_datetime datetime DEFAULT '2016-03-31 16:00:00'; WHILE var < loop_times DO insert INTO his_log (cid,uid,mac,inpuId,listId,templeteId,originPath,browseTime,browseNum,ip,province,city) VALUES (1,1001,'00-01-02-10-23',1000233,189,1,0,l_datetime,var,'12.56.36.123','广东省','深圳市'); SET var = var + 1; SET l_datetime = DATE_ADD(l_datetime,INTERVAL 1 HOUR); END WHILE; END // DELIMITER ; call insert_logs_test_4(25) // 若要在i ≤ R ≤ j 这个范围得到一个随机整数R FLOOR(i + RAND() * (j – i + 1)) FLOOR(0 + RAND() * (24 – 0 + 1))