MySQL statements generate large amounts of test data in batches

Source: Internet
Author: User

CREATE TABLE ' T_user ' (
' ID ' bigint (a) not NULL auto_increment,
' Name ' varchar (255) DEFAULT NULL,
' Age ' tinyint (4) DEFAULT NULL,
' Create_time ' datetime DEFAULT NULL,
' Update_time ' datetime DEFAULT NULL,
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT Charset=utf8;

DELIMITER $$ By default DELIMITER is a semicolon and now defines the Terminator as $$.
Drop PROCEDURE if EXISTS {PROCEDURE} before deleting to determine whether the specified table or stored procedure exists
Create PROCEDURE creating a stored procedure
Begin
DECLARE Pre_name BIGINT; Define Prename as bigint type
DECLARE Ageval INT;
DECLARE i INT;
SET pre_name=187635267;
SET ageval=100;
SET I=1;
While I < 1000000 do
INSERT into T_user (' name ', Age,create_time,update_time) VALUES (CONCAT (Pre_name, ' @qq. com '), (ageval+1)%30,now (), Now ( ));
SET pre_name=pre_name+100;
SET i=i+1;
END while;
END $$

delimiter;
Call Proc_batch_insert (); Invoke a defined function

MySQL statements generate large amounts of test data in batches

Related Article

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.