通过编写mysql函数实现批量插入压测数据

DROP PROCEDURE
IF
EXISTS `insertdata`;
CREATE PROCEDURE `insertdata` ( IN count INTEGER, IN idstart INTEGER, IN skillidstart INTEGER ) BEGIN
DECLARE
number INTEGER;
SET number = 1;
START TRANSACTION;
WHILE
number <= count DO
INSERT INTO `ski_ta` ( `id`, `skill_id`, `skill_name`, `hotline_id`, `wecare_renter_id`, `tag_key_id`, `tag_value_id` )
VALUES
( idstart, skillidstart, '批量数据压测队列', 'WC_20000000000000000000000000000214', '00000000000000000000000000000214', 870387601160540160, 870412249721999360 );
SET number = number + 1;
SET idstart = idstart + 1;
SET skillidstart = skillidstart + 1;
END WHILE;
COMMIT;
END
CREATE DEFINER=`root`@`%` PROCEDURE `insertdata`( 
IN count BIGINT,
IN idstart BIGINT,
IN skillidstart BIGINT,
IN tagkeyid BIGINT,
IN tagvalueid BIGINT
)
BEGIN
DECLARE
number INTEGER;
SET number = 1;
START TRANSACTION;
WHILE
number <= count DO
			INSERT INTO
			`table_name` ( `id`, `skill_id`, `skill_name`, `hotline_id`, `wecare_renter_id`, `tag_key_id`, `tag_value_id`, `created_by`, `creation_date`, `last_updated_by`, `last_update_date` )
		VALUES
			( idstart, skillidstart, '批量数据压测技能队列', 'WC_20000000000000000000000000000214', '00000000000000000000000000000215', tagkeyid, tagvalueid, '压测脚本', '2023-08-02 10:50:54', '压测脚本', '2023-08-02 10:50:54' );
SET number = number + 1;
SET idstart = idstart + 1;
SET tagkeyid = tagkeyid + 1;
SET tagvalueid = tagvalueid + 1;
END WHILE;
COMMIT;
END

你可能感兴趣的:(java,数据库)