mysql事务

#向emp表中插入记录(海量的数据)


delimiter $$
drop procedure insert_emp $$



create procedure insert_emp(in start int(10),in max_num int(10))
begin
declare i int default 0; 
 set autocommit = 0;  
 repeat
 set i = i + 1;
 insert into emp values ((start+i) ,rand_string(6),'SALESMAN',0001,curdate(),2000,400,rand_num());
  until i = max_num
 end repeat;
   commit;
 end $$


delimiter ;
#调用刚刚写好的函数, 1800000条记录,从100001号开始
call insert_emp(100001,1800000);

 

posted @ 2016-03-29 17:31  雨落知音  阅读(123)  评论(0编辑  收藏  举报