查看: 436|回复: 0

mysql-proc

 关闭 [复制链接]

签到天数: 2593 天

连续签到: 7 天

[LV.Master]至尊海神IIIIII

发表于 2010-8-30 19:33 | 显示全部楼层 |阅读模式
mysql-proc


delimiter //  
drop procedure autoinsert if exist autoinsert //
create procedure autoinsert()   
begin
    declare i int default 1;   
    while (i <= 100000) do   
        insert into test.t_count (a) values(i);   
        set i = i+1;   
    end while;   
end
//
delimiter ;


CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_isam`(p int,t char(10))
begin
set @i = 0;
set @str = “iamauperman!iwillbeahero!!”;
repeat
#select name into @str from mysql.help_topic order by rand() limit 1;
set @str=substr(@str,1,25);
set @ins_str = repeat(@str,floor(rand()*10));
set @cmd=concat(‘insert into ‘,t,’ (content) values(“‘,@ins_str,’”)’);
prepare stmt from @cmd;
execute stmt;
set @i = @i+1;
until @i > p end repeat;
end
<
PCOS系统下载站:http://zhuangji.wang

本版积分规则