Insert data cyclically in MySQL stored procedures

Source: Internet
Author: User

When testing machines, you often need to test the absolute values of inset and alert. Therefore, you have written a stored procedure to complete the test.
 

Drop procedure if exists proc_buildata;
Tudou @ Gyyx
Create procedure proc_buildata (IN loop_times INT)
BEGIN
DECLARE var int default 0;
 
Prepare msql from 'create table if not exists 'Employee' ('id' int (10) unsigned not null AUTO_INCREMENT, 'employeeid' int (10) unsigned not null comment '0', 'ployeename' varchar (64) not null default ''', primary key ('id') ENGINE = innodb ';
Execute msql;
 
WHILE var <loop_times DO
SET var = var + 1;
Insert into employee (employeeid, employeename) VALUES (var, CONCAT ('test', var ));
 
End while;
END
 
CALL proc_buildata (1, 2000000 );
 
 
Select count (1) FROM employee;

From the column of ylqmf

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.