mysql 循环插入表

DELIMITER:
CREATE PROCEDURE test_insert()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i<100
DO
insert into test(id, name) values (i, i);
SET i=i+1;
END WHILE ;
commit;

END;

CALL test_insert();

 

 

 

 

 

 

DELIMITER:
CREATE PROCEDURE test_insert()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i<30
DO
insert into pl_shop_daily_report(shop_id, barcode, return_goods_count, return_count, report_date) values ('1064705652215865345', i, i, i, CONCAT(2019, '-' ,11, '-' , i ));
SET i=i+1;
END WHILE ;
commit;

END;

CALL test_insert();

 

posted @ 2017-02-09 11:10  he0xff  阅读(453)  评论(0编辑  收藏  举报