Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly create millions of Test data by MySQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces MySQL how to quickly create millions of test data, the content is very detailed, interested friends can refer to it, I hope it can help you.

CREATE TABLE `vote_record_memory` (

`id` INT (11) NOT NULL AUTO_INCREMENT,

`user_id` VARCHAR (20) NOT NULL,

`vote_id` INT (11) NOT NULL,

`group_id` INT (11) NOT NULL,

`create_time` datetime NOT NULL,

PRIMARY KEY (`id`),

KEY `index_id` (`user_id`) USING HASH

) ENGINE = memory AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 ;

CREATE TABLE `vote_record` (

`id` INT (11) NOT NULL AUTO_INCREMENT,

`user_id` VARCHAR (20) NOT NULL,

`vote_id` INT (11) NOT NULL,

`group_id` INT (11) NOT NULL,

`create_time` datetime NOT NULL,

PRIMARY KEY (`id`),

KEY `index_user_id` (`user_id`) USING HASH

) ENGINE = INNODB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 ;

DELIMITER //

CREATE FUNCTION `rand_string`(n INT) RETURNS varchar(255) CHARSET latin1

BEGIN

DECLARE chars_str varchar(100) DEFAULT 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

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()*62 ),1));

SET i = i +1;

END WHILE;

RETURN return_str;

END //

DELIMITER //

CREATE PROCEDURE `add_vote_memory`(IN n int)

BEGIN

DECLARE i INT DEFAULT 1;

WHILE (i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report