1. Sort out the relationship between the tables
2. First set the delimiterThe role of delimiter: tell the interpreter whether this command has ended and whether mysql can be executed. By default, delimiter is ';' but when we write procedure, if it is the default setting, then a When encountering ';', mysql will execute, which we do not want to see,
so we manually set the delimiter to //
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), 'da1de60be9c4b17c0106cfa0865ea9fdacd52"bda', 'JJOiOP8nJ@&m^ZLzuuC9stestAe2",LzuuC9s(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//
#Where concat("test", num) is equivalent to the splicing effect of test||num in Oracle, but mysql does not support such splicing
show create procedure myproc;
call myproc();
5. After the data is inserted successfully, delete myproc()
drop procedure myproc;
6. Check whether the user data is inserted successfully
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. Get data and import csv file
select user_id,'test' from user where user_id like 'test%' order by user_id;