BEGINDECLARE v INT;SET v = 0;REPEATselect concat(
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end
) as keka;insert into table1 (a,b)
values(CONCAT('($%)F',keka),'e51d744514b334228d43dd605d556a61');
SET v = v + 1;UNTIL v >= 5 <--END REPEAT;
END
table1中的a是有固定的字符串+隨機的字符串組成,
但上面的執行有錯,哪位大俠幫忙改下
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end
) as keka;insert into table1 (a,b)
values(CONCAT('($%)F',keka),'e51d744514b334228d43dd605d556a61');
SET v = v + 1;UNTIL v >= 5 <--END REPEAT;
END
table1中的a是有固定的字符串+隨機的字符串組成,
但上面的執行有錯,哪位大俠幫忙改下
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end
) INTO @keka;
insert into table1 (a,b)
values(CONCAT('($%)F',@keka),'e51d744514b334228d43dd605d556a61');
Query OK, 0 rows affected (0.06 sec)mysql> create table table1 (a char(20),b char(35));
Query OK, 0 rows affected (0.16 sec)mysql> delimiter //
mysql>
mysql> CREATE PROCEDURE dorepeat()
-> BEGIN
->
-> DECLARE v INT default 0;
->
-> REPEAT
-> insert into table1 (a,b)
-> values(concat('($%)F',
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end,
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end,
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end,
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end,
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end,
-> case when round((rand())*25) > 12 then char(round((rand(
))*25)+97) else char(round((rand())*25)+65) end
-> ),'e51d744514b334228d43dd605d556a61');
->
-> SET v = v + 1;
-> UNTIL v >= 5 END REPEAT;
-> END
-> //
Query OK, 0 rows affected (0.25 sec)mysql> delimiter ;
mysql>
mysql> CALL dorepeat();
Query OK, 1 row affected (0.19 sec)mysql> select * from table1;
+-------------+----------------------------------+
| a | b |
+-------------+----------------------------------+
| ($%)FBjKgGo | e51d744514b334228d43dd605d556a61 |
| ($%)FkpLkKv | e51d744514b334228d43dd605d556a61 |
| ($%)FIXUrwh | e51d744514b334228d43dd605d556a61 |
| ($%)FoajRnn | e51d744514b334228d43dd605d556a61 |
| ($%)FZikkUT | e51d744514b334228d43dd605d556a61 |
+-------------+----------------------------------+
5 rows in set (0.00 sec)mysql>