MySQL 随机密码生成代码

2023年 4月 19日 48.7k 0

复制代码 代码如下: 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

复制代码 代码如下: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);

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论