首页  >  文章  >  数据库  >  MySQL快速插入大批量数据存储过程_MySQL

MySQL快速插入大批量数据存储过程_MySQL

WBOY
WBOY原创
2016-06-01 13:38:49900浏览

bitsCN.com


MySQL快速插入大批量数据存储过程

 

[html]    

-- ----------------------------  

-- Table structure for `test`  

-- ----------------------------  

DROP TABLE IF EXISTS `test`;  

CREATE TABLE `test` (  

  `id` int(11) NOT NULL AUTO_INCREMENT,  

  `ordernum` varchar(255) NOT NULL,  

  PRIMARY KEY (`id`)  

) ENGINE=InnoDB AUTO_INCREMENT=500001 DEFAULT CHARSET=utf8;  

  

begin  

set @beginnum=1;  

set @endnum=500001;  

  

start transaction;  

while @beginnum

  

set @v_beginnum=LPAD(@beginnum,7,0);  

set @order=concat(20121105,@v_beginnum);  

  

INSERT INTO test ( ordernum )  

VALUES  

    (  

        @order  

    );  

  

    set @beginnum=@beginnum+1;  

 end while;  

 commit;  

 end  
 

bitsCN.com
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn