MySQL 随机密码生成代码

很文博客hinven.com 数据库评论222字数 645阅读模式
广告也精彩

晚上有朋友问起,简单的写了一个。

  1. DELIMITER $$
  2. CREATE
  3. FUNCTION `t_girl` . `func_rand_string` ( f_num tinyint unsigned , f_type tinyint unsigned )
  4. RETURNS varchar ( 32)
  5. BEGIN
  6. -- Translate the number to letter.
  7. -- No 1 stands for string only.
  8. -- No 2 stands for number only.
  9. -- No 3 stands for combination of the above.
  10. declare i int unsigned default 0;
  11. declare v_result varchar ( 255) default '' ;
  12. while i < f_num do
  13. if f_type = 1 then
  14. set v_result = concat ( v_result, char ( 97+ ceil( rand ( ) * 25) ) ) ;
  15. elseif f_type= 2 then
  16. set v_result = concat ( v_result, char ( 48+ ceil( rand ( ) * 9) ) ) ;
  17. elseif f_type= 3 then
  18. set v_result = concat ( v_result, substring ( replace ( uuid ( ) , '-' , '' ) , i+ 1, 1) ) ;
  19. end if;
  20. set i = i + 1;
  21. end while;
  22. return v_result;
  23. END $ $
  24. DELIMITER ;

调用方法示例:文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/50333.html

  1. select func_rand_string(12,3);
文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/50333.html文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/50333.html

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证