Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Dummy Data with MySQL Stored Proc
/* based on https://stackoverflow.com/a/17268740/288935 */
CREATE PROCEDURE insert_test_data()
BEGIN
DECLARE i INT default 1;
DECLARE mydate DATE DEFAULT NOW();
SET mydate = DATE_ADD('2017-05-01 00:01:00', INTERVAL FLOOR(RAND() * 700) DAY);
WHILE i < 1000000 DO
INSERT INTO `telemetry_test` (`humidity`, `temperature`, `sql_insert`, `sql_update`)
select
FLOOR(RAND() * 40), FLOOR(RAND() * 80), mydate, mydate;
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;
CALL insert_test_data();
DROP PROCEDURE insert_test_data;
@theothermattm

This comment has been minimized.

Copy link
Owner Author

theothermattm commented Aug 20, 2019

Takes a while to run..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.