MySQL BULK insert 500 piece of data

Source: Internet
Author: User
Tags bulk insert

The table structure is as follows

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9E/42/wKioL1mOl66xQ0a1AAA6Sw4G6jw633.png "title=" 1.png "alt=" Wkiol1mol66xq0a1aaa6sw4g6jw633.png "/>


The requirements name and password fields, which generate the following format:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9E/53/wKiom1mOl_2xEMqsAAA5NX-pdNU972.png "title=" 2.png "alt=" Wkiom1mol_2xemqsaaa5nx-pdnu972.png "/>



Generate 500 batches in total.


Solution Ideas:

    1. MySQL stored procedures can be used

    2. If you can use the shell in a Linux environment



Let's first test the first, with the stored procedure.

DELIMITER;; # #定义;;        For Terminator create PROCEDURE Test_insert () # #创建存储过程 Test_insert () is the name begin DECLARE y int DEFAULT 1;  # #定义y is an integer default starting value is 1WHILE Y<500doinsert into test1 (Name,password,reallyname,age,profession,email,question,result) VALUES (concat (' test ', y), concat (' test ', y), ' Jiang ', ' i ', ' hello ', ' hello ', ' hello ', ' hello ');       SET y=y+1; # #y数值加1END while; Commit END;;


Define complete stored procedure Test_insert ()

Execute command call Test_insert () automatically generate 500 data


Problems encountered during the period:

At the beginning,

DECLARE y int DEFAULT 1 incomplete, this command I wrote: DECLARE y TINYINT The default 1 stored procedure is established, the execution of the dead loop, and the insertion of the Y maximum is 127, the reason behind check, found that the TINYINT maximum value of 127 changes into int, the execution succeeds.


This article is from the "Gome Learning" blog, so be sure to keep this source http://goome.blog.51cto.com/4045241/1955738

MySQL BULK insert 500 piece of data

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.