mysql random 字母大小写和数字

delimiter $$
drop function if exists rand_string;
create function rand_string(n int) returns varchar(255)
begin
declare chars_str varchar(52) 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 $$

原文地址:https://www.cnblogs.com/shenwenkai/p/11155625.html