MySQL随机密码的实例代码

来源:爱站网时间:2022-10-03编辑:网友分享
今天给大家分享下MySQL随机密码的实例代码知识点,需要了解清楚这方面内容的小伙伴可以看看爱站技术频道小编所整理的资料,千万不要错过了。
复制代码 代码如下:

DELIMITER $$

CREATE
FUNCTION `t_girl` . `func_rand_string` ( f_num tinyint unsigned , f_type tinyint unsigned )
RETURNS varchar ( 32)
BEGIN
-- Translate the number to letter.
-- No 1 stands for string only.
-- No 2 stands for number only.
-- No 3 stands for combination of the above.
declare i int unsigned default 0;
declare v_result varchar ( 255) default '' ;
while i if f_type = 1 then
set v_result = concat ( v_result, char ( 97+ ceil( rand ( ) * 25) ) ) ;
elseif f_type= 2 then
set v_result = concat ( v_result, char ( 48+ ceil( rand ( ) * 9) ) ) ;
elseif f_type= 3 then
set v_result = concat ( v_result, substring ( replace ( uuid ( ) , '-' , '' ) , i+ 1, 1) ) ;
end if;
set i = i + 1;
end while;
return v_result;

END $ $

DELIMITER ;


调用方法示例:

代码如下:

select func_rand_string(12,3);

MySQL随机密码的实例代码内容不知道各位小伙伴都掌握了没有,在我们爱站技术频道网站有很多不同类型的技术文章,如果你喜欢记得关注收藏下。 

上一篇:如何批量替换MySQL指定字符串

下一篇:MYSQL语句优化的使用

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载