mysql 循环生成数据demo:
DROP PROCEDURE IF EXISTS test_insert; DELIMITER;; CREATE PROCEDURE test_insert() BEGIN DECLARE i INT DEFAULT 1; DECLARE time VARCHAR(50) ; DECLARE id VARCHAR(50) ; DECLARE caseId VARCHAR(50) DEFAULT 'case001'; DECLARE yearMonth VARCHAR(50) DEFAULT '2021-06'; DECLARE clearNodeId VARCHAR(50) DEFAULT '1234567'; DECLARE clearNodeNamde VARCHAR(50) DEFAULT 'xxxxy'; DECLARE clearingNodeType INT DEFAULT 1; DECLARE contractNo VARCHAR(50) DEFAULT '1234'; WHILE i < 31 DO CASE i WHEN i<10 THEN SET time= CONCAT('2021-06-0',i, ' 00:00:00'); ELSE SET time= CONCAT('2021-06-',i, ' 00:00:00'); END CASE; SET id= replace(uuid(),"-",""); INSERT INTO `test_table` VALUES (id, caseId, yearMonth, clearNodeId, clearNodeNamde, clearingNodeType, contractNo, time); SET i = i + 1; END WHILE; COMMIT; END;; CALL test_insert();
仅作为笔记,欢迎参考;