1.创建存储过程
右键函数,新建函数


2. 创建函数或者存储过程
填入参数

3. 填写存储过程代码
随机往aws_action表中插入数据
BEGIN
DECLARE i int UNSIGNED;
DECLARE t int UNSIGNED;
set i=1;
set t=1529370782;
while i<=num DO
if(i%50=0) then
set t=t+FLOOR(1+RAND()*18);
ELSE
set t=t+FLOOR(1+RAND()*10000);
end if;
insert into aws_action(item_id,user_id,start_time) values(FLOOR(11000+RAND()*60000),FLOOR(1+RAND()*17),t);
set i = i + 1;
end while;
END
- 原始SQL语句
DROP PROCEDURE IF EXISTS `insertaction`;
CREATE DEFINER = `root`@`%` PROCEDURE `insertaction`(IN `num` int)
BEGIN
DECLARE i int UNSIGNED;
DECLARE t int UNSIGNED;
set i=1;
set t=1529370782;
while i<=num DO
if(i%50=0) then
set t=t+FLOOR(1+RAND()*18);
ELSE
set t=t+FLOOR(1+RAND()*10000);
end if;
insert into aws_action(item_id,user_id,start_time) values(FLOOR(11000+RAND()*60000),FLOOR(1+RAND()*17),t);
set i = i + 1;
end while;
END;
博客介绍了存储过程的创建方法,包括右键函数新建函数,创建函数或存储过程时填入参数,还给出了往aws_action表随机插入数据的存储过程代码及原始SQL语句。
908

被折叠的 条评论
为什么被折叠?



