MySQL automatically inserts millions of simulated data operation code

MySQL automatically inserts millions of simulated data operation code

I use Navicat as my database tool. Others are similar.

1. Open navicat, there is a function menu under the corresponding database, right click to create a new function ==》Complete

2. Create a test table user. I am too lazy to write statements because everyone needs different tables.

3. Create a function and directly put the code! Note that the insert statement in the middle is replaced with the insert statement you need. You can use the random method to ensure that the generated data is different.

CREATE DEFINER=`root`@`localhost` FUNCTION `ins_data`(`num` int) RETURNS int(11)
BEGIN
DECLARE i int DEFAULT 0;
WHILE i<num DO
INSERT INTO `user` (`name`,email,phone,sex,password,age,create_time)
values(concat('User',i),'[email protected]'
,CONCAT('18',FLOOR(rand()*(999999999-100000000)+100000000))
,FLOOR(RAND()*2),UUID(),FLOOR(RAND()*100)
,now());
set i = i+1;
END WHILE;
RETURN i;
END

4. Test, the return value is the number of data generated.

Note: It may take several minutes to generate 1 million pieces of data. Performing other operations during the process may result in failure.

Done!

This is the end of this article about MySQL automatic insertion of millions of simulated data. For more relevant MySQL automatic data insertion content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 4 ways to optimize MySQL queries for millions of data
  • MySQL single table million data records paging performance optimization skills
  • How to quickly insert millions of test data in MySQL
  • Implementation of inserting millions of records into MySQL database within 10 seconds

<<:  Practice of implementing custom search bar and clearing search events in avue

>>:  How to remove the dotted border when clicking a link in FireFox

Recommend

Vue2.x - Example of using anti-shake and throttling

Table of contents utils: Use in vue: explain: Ima...

CSS scroll-snap scroll event stop and element position detection implementation

1. Scroll Snap is a must-have skill for front-end...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

How to deploy redis in linux environment and install it in docker

Installation Steps 1. Install Redis Download the ...

React Hooks Common Use Scenarios (Summary)

Table of contents 1. State Hook 1. Basic usage 2....

MySQL Error 1290 (HY000) Solution

I struggled with a problem for a long time and re...

Detailed steps to install MySQL on CentOS 7

In CentOS7, when we install MySQL, MariaDB will b...

Detailed explanation and extension of ref and reactive in Vue3

Table of contents 1. Ref and reactive 1. reactive...

How to add, delete and modify columns in MySQL database

This article uses an example to describe how to a...

The whole process of installing gogs with pagoda panel and docker

Table of contents 1 Install Docker in Baota Softw...

HTML optimization speeds up web pages

Obvious HTML, hidden "public script" Th...

MySQL database JDBC programming (Java connects to MySQL)

Table of contents 1. Basic conditions for databas...

Detailed explanation of Javascript closures and applications

Table of contents Preface 1. What is a closure? 1...