Get the App
SLTechnology News&Howtos  ›  Database  › 

How to create tens of millions of pressure test data according to the table in MySQL

Shulou Source: shulou.com Published: 2022-05-31 19:03:30 10月03日 Update

In this issue, the editor will bring you about how to create tens of millions of stress test data according to the table in MySQL. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

1. Prepare the test table

CREATE TABLE `username` (`uid` INT (11) UNSIGNED NOT NULL default 1235678901, `username` VARCHAR (20), `email` VARCHAR (30), `password` VARCHAR (32), `day` date, `gender` VARCHAR (10), avatar MEDIUMBLOB, PRIMARY KEY (`uid`) ENGINE = INNODB DEFAULT CHARSET=utf8

two。 Randomly generated data

MySQL comes with a random number generated function RAND (), which can generate 0-1 floating point numbers.

The RAND function generates random numbers:

SET GLOBAL log_bin_trust_function_creators = 1

CREATE DEFINER = `root` @ `% `FUNCTION `root` rand_ string` (n INT) RETURNS VARCHAR

DECLARE

Chars_str VARCHAR DEFAULT 'hwbtestABCDEFG23141HIJ6712dfghjkqwevbnqmwerqwerqwreqw214123e1214c12dssaf89'

DECLARE

Return_str VARCHAR (255) DEFAULT''

DECLARE

I INT DEFAULT 0

WHILE

I < n DO

SET return_str = concat (return_str, substring (chars_str, FLOOR (1 + RAND () * 80), 1))

SET ii = I + 1

END WHILE

RETURN return_str

END

Tags: Data generation type content function process random number analysis storage loop professional small and medium rich in content that is articles more months points knowledge articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Apple vpn Redmi