#创建库和表
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1(id INT,nam VARCHAR(10),age int);
#定义一个存储过程,插入数据
DELIMITER $$
CREATE PROCEDURE p2(IN num INT)
BEGIN
DECLARE FIRST_N varCHAR(1000);
DECLARE LAST_N VARCHAR(1000);
DECLARE C1 VARCHAR(4);
DECLARE C2 INT;
DECLARE i INT DEFAULT 0;
SET FIRST_N='王李张刘陈杨黄赵吴周徐孙马朱胡郭何高林罗郑梁谢宋唐位许韩冯邓曹彭曾萧田董潘袁于蒋蔡余杜叶程苏魏吕丁任沈姚卢姜崔钟谭陆汪范金石廖贾夏韦傅方白邹孟熊秦邱江尹薛阎段雷侯龙史陶黎贺顾毛郝龚邵万钱严覃武戴莫孔向汤';
SET LAST_N='丹举义之乐书乾云亦从代以伟佑俊修健傲儿元光兰冬冰冷凌凝凡凯初力勤千卉半华南博又友同向君听和哲嘉国坚城夏夜天奇奥如妙子存季孤宇安宛宸寒寻尔尧山岚峻巧平幼康建开弘强彤彦彬彭心忆志念怀怜恨惜慕成擎敏文新旋旭昊明易昕映春昱晋晓晗晟景晴智曼朋朗杰松枫柏柔柳格桃梦楷槐正水沛波泽洁洋济浦浩海涛润涵渊源溥濮瀚灵灿炎烟烨然煊煜熙熠玉珊珍理琪琴瑜瑞瑶瑾璞痴皓盼真睿碧磊祥祺秉程立竹笑紫绍经绿群翠翰致航良芙芷苍苑若茂荣莲菡菱萱蓉蓝蕊蕾薇蝶觅访诚语谷豪赋超越轩辉达远邃醉金鑫锦问雁雅雨雪霖霜露青靖静风飞香驰骞高鸿鹏鹤黎';
WHILE i<num DO
SET C1=CONCAT(SUBSTR(FIRST_N,FLOOR(RAND()*LENGTH(FIRST_N)/3+1),1), SUBSTR(LAST_N,FLOOR(RAND()*LENGTH(LAST_N)/3+1),1), SUBSTR(LAST_N,FLOOR(RAND()*LENGTH(LAST_N)/3+1),1));
SET C2=FLOOR(18+RAND()*(60-18));
SET i=i+1;
INSERT INTO t1 VALUES(i,C1,C2);
END WHILE;
END;$$
DELIMITER ;
#调用存储过程,插入100万行数据
CALL p2(1000000);