MySQL 随机密码生成代码

1006616047

1006616047

2016-02-19 09:27

有了下面这个MySQL 随机密码生成代码教程,不懂MySQL 随机密码生成代码的也能装懂了,赶紧get起来装逼一下吧!
代码如下:

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);
展开更多 50%)
分享

猜你喜欢

MySQL 随机密码生成代码

编程语言 网络编程
MySQL 随机密码生成代码

生成sessionid和随机密码的例子

PHP
生成sessionid和随机密码的例子

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

产生随机密码的函数

ASP
产生随机密码的函数

开机密码

编程语言 网络编程
开机密码

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

怎么设置开机密码 开机密码的设置方法

电脑 密码
怎么设置开机密码 开机密码的设置方法

MySQL随机选取数据

编程语言 网络编程
MySQL随机选取数据

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

ORACLE 数据库RMAN备份恢复

ORACLE 数据库RMAN备份恢复

ECMAScript 基础知识

ECMAScript 基础知识
下拉加载更多内容 ↓