(十)、造性能测试用户数据
1. 梳理各表关联关系
2. 首先设置delimiterdelimiter的作用:告诉解释器,这段命令是否已经结束了,mysql是否可以执行了 ,默认情况下,delimiter是‘;’但是当我们编写procedure时,如果是默认设置,那么一遇到‘;’,mysql就要执行,这是我们不希望看到的
所以我们手动设置delimiter为//
delimiter//
create procedure myproc()
begin
declare num int;
set num=1;
while num < 10000 do
INSERT INTO user (user_id, user_password, salt, user_name, belong_to_unit_type, belong_to_type_unit_id, avatar_url_type, avatar_url) VALUES (concat("test", num), 'da1de60be9c4b17c0106cfa0865ea9fdacd52bda', '[email protected]&m^ZLzuuC9sAe2LbZoNIlc', concat("test", num), '2', 'guangdong_gzw', '2', 'www.ggkbigdata.com');
INSERT INTO user_role (user_id, role_id) VALUES (concat("test", num),'1');
INSERT INTO user_permission (user_id, permission_id) VALUES (concat("test", num),'1');
set num=num+1;
end while;
end//
#其中concat(“test”, num),相当于Oracle中test||num的拼接效果,但是mysql不支持这样拼接
show create procedure myproc;
call myproc();
5. 数据插入成功后,删除myproc()
drop procedure myproc;
6. 检查用户数据是否插入成功
select * from user where user_id like 'test%' order by user_id;
select * from user_role where user_id like 'test%' order by user_id;
select * from user_permission where user_id like 'test%' order by user_id;
7. 获取数据导入csv文件
select user_id,'test' from user where user_id like 'test%' order by user_id;