delimiter // CREATE PROCEDURE init_school() BEGIN DECLARE schid INT; SET schid = 0; START TRANSACTION; WHILE schid < 100 DO insert into school(school_code,school_name) values (concat('code',schid),concat('name',schid)); SET schid = schid + 1; END WHILE; COMMIT; END // delimiter ;
delimiter // CREATE PROCEDURE init_student() BEGIN DECLARE schid INT; DECLARE stuid INT; SET schid = 0; WHILE schid < 100 DO SET stuid = 0; START TRANSACTION; WHILE stuid < 50 DO insert into student(school_code,student_name) values (concat('code',schid),concat('stu_name',stuid)); SET stuid = stuid + 1; END WHILE; SET schid = schid + 1; COMMIT; END WHILE; END // delimiter ;