Code implementation for adding and deleting massive data in a mysql data table

Source: Internet
Author: User
The code for adding and deleting massive amounts of data to and from a mysql data table needs to be tested today. However, the data source in the data table has become a major problem, and the same problem occurs when you search online.

Recommended methods include:

1. add in excel and import it to the data table (feasible but troublesome)

2. manually add one by yourself (cannot stand it, drive people crazy)

3. use a program to add data cyclically (very convenient and practical)

The following is a brief introduction to the third scenario:


Let's just give a chestnut,


Drop procedure if exists km; // The km method needs to be deleted each time. Otherwise, the program cannot execute create procedure km () for the second time. // create a km method begin declare I int; set I = 0; while I <= 1000 do insert into de_grade ('atient _ id', 'case _ name', 'User _ name', 'case _ level ', 'grade _ type', 'grade ') values (1006, 'heart', 'jungl', 9, 2, 84.48); set I = I + 1; end while; end; call km (); // CALL method execution

Similarly, you can delete multiple objects in a loop (delete them by id)

Drop procedure if exists km; create procedure km () begin declare I int; set I = 100; while I <= 200 do delete from de_grade where grade_id = I; set I = I + 1; end while; end; CALL KM ();

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.