码迷,mamicode.com
首页 > 其他好文 > 详细

存储过程批量插入

时间:2016-10-19 13:48:49      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

CREATE DEFINER=`root`@`%` PROCEDURE `batchInsert`(IN loop_times INT)
BEGIN  
     DECLARE var INT;   
     SET var = 0;  
     set @exeSql=concat("insert into cdb_dynamic (typeId,addTime,userId) VALUES (1,1470540371,1)");  
            
     WHILE var < loop_times DO  
           set @exeSql=concat(@exeSql,", (1,1470540371,1)");  
           SET var = var + 1;  
     END WHILE;  
     prepare stmt from @exeSql;  
     EXECUTE stmt;  
     deallocate prepare stmt;
     END;

 

存储过程批量插入

标签:

原文地址:http://www.cnblogs.com/zenghansen/p/5976700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!