首页 > 代码库 > 存储过程批量插入

存储过程批量插入

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;

 

存储过程批量插入