时间:2021-07-01 10:21:17 帮助过:21人阅读
2.生成手机号码
#生成随机手机号码 # 定义常用的手机头 130 131 132 133 134 135 136 137 138 139 186 187 189 151 157 #SET starts = 1+floor(rand()*15)*4; 截取字符串的开始是从 1、5、9、13 ...开始的。floor(rand()*15)的取值范围是0~14 #SET head = substring(bodys,starts,3);在字符串bodys中从starts位置截取三位 DELIMITER $$ CREATE FUNCTION generatePhone() RETURNS varchar(20) BEGIN DECLARE head char(3); DECLARE phone varchar(20); DECLARE bodys varchar(100) default "130 131 132 133 134 135 136 137 138 139 186 187 189 151 157"; DECLARE starts int; SET starts = 1+floor(rand()*15)*4; SET head = trim(substring(bodys,starts,3)); SET phone = trim(concat(head,randNum(8))); RETURN phone; END $$ DELIMITER ;
3.生成随机字符串
#创建随机字符串和随机时间的函数 DELIMITER $$ CREATE FUNCTION `randStr`(n INT) RETURNS varchar(255) CHARSET utf8mb4 DETERMINISTIC BEGIN DECLARE chars_str varchar(100) DEFAULT ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789‘; DECLARE return_str varchar(255) DEFAULT ‘‘ ; DECLARE i INT DEFAULT 0; WHILE i < n DO SET return_str = concat(return_str, substring(chars_str, FLOOR(1 + RAND() * 62), 1)); SET i = i + 1; END WHILE; RETURN return_str; END$$ DELIMITER;
CSDN:https://blog.csdn.net/wuzhangweiss/article/details/101156910
MySQL查询速度测试->连接查询
标签:连接查询 pre tps arc font _id bsp end actor