mysql

推荐列表 站点导航

当前位置:首页 > 数据库 > mysql >

MySQL 随机密码生成代码

来源:网络整理  作者:网络  发布时间:2020-12-09 06:40
晚上有朋友问起,简单的写了一个。 DELIMITER $$ CREATE FUNCTION `t_girl` . `func_rand_string` ( f_num tinyint unsigned , f_type tinyint u...
晚上有朋友问起,简单的写了一个。   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 < f_num do 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

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/sql/mysql/1715.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

MySQL 随机密码生成代码

2020-12-09 编辑:网络

晚上有朋友问起,简单的写了一个。   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 < f_num do 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);   

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/sql/mysql/1715.shtml

相关文章

风云图片

推荐阅读

返回mysql频道首页