Personal backup-mysql Stored Procedure

Source: Internet
Author: User

/* Parameter: Start ID, customer ID, number of records, initial user name */
Delimiter $
Create procedure batchinsert (in init int, in CID int, in loops int, in username varchar (64 ))
Begin
Declare myid int;
Declare myname varchar (64 );
Declare num int;
Set myid = Init;
Set myname = username;
Set num = 1;
While num <= loops do
Set myname = Concat (username, convert (myid, char ));
/* Insert a user into the user table */
Insert into user (ID, CID, name, realname, photo, experience, register_date, modify_date)
Values (myid, CID, myname, myname, 'www .baidu.com ', 1200.00, now (), now ());
/* Insert the user's experience record into the experience table */
Insert into user_experience (CID, name, qid, aid, exp_reg, tags, create_date, modify_date, exp_status)
Values (CID, myname, 10000,100 00, 3.14, 'AB, CD, ee', now (), now (), 2 );
Set num = num + 1;
Set myid = myid + 1;
End while;
End $

Call batchinsert (5000, 'aaa ');
Call batchinsert (5000, 'bbb ');

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.