MySQL add items Test Data

Demand scenario

Project development process, a function requires a lot of data to support our validation logic performance, we can remove after testing is complete, confirm that R & D function is available. If you go to a new article, it would take a very large time cost, when the subsequent cut is required, we have re-built data.

solution

Through which we can create a custom mysql function that projects through the business to decide which new data, and use this function to direct the next time the need to achieve, can simulate multiple scenarios.

delimiter $$$
create procedure batchInsert()
begin
declare i int default 0;
set i=0;
start transaction;
while i<80000 do
 //your insert sql 
set i=i+1;
end while;
commit;
end
$$$
delimiter;

After executing the above SQL, will create a stored procedure in the database, we simply call can only add bulk to perform the number of data.

call batchInsert();

Forget to add 80000 data in the database after the call batchInsert ()

Points:
1 // SQL INSERT your
writing to add data need to perform this SQL
2 can edit the number of control generation of the Number
3call to call a function executable

Released seven original articles · won praise 6 · views 8173

Guess you like

Origin blog.csdn.net/YaoWu_Zhou/article/details/105076091