国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL 隨機密碼生成代碼

2024-07-24 13:00:39
字體:
來源:轉載
供稿:網友

晚上有朋友問起,簡單的寫了一個。

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); 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凤翔县| 巴青县| 蚌埠市| 永仁县| 广饶县| 磐石市| 黄山市| 额敏县| 潜江市| 邯郸市| 新建县| 淮阳县| 抚远县| 尉氏县| 磐石市| 威信县| 和静县| 东方市| 长春市| 斗六市| 永兴县| 灵寿县| 宣汉县| 闽侯县| 新源县| 稷山县| 三门峡市| 百色市| 兴国县| 潼关县| 海兴县| 额尔古纳市| 大关县| 郁南县| 玛沁县| 马边| 沁水县| 霍城县| 丰原市| 江西省| 化州市|