MySQL 隨機(jī)密碼生成代碼
更新時(shí)間:2009年09月12日 22:15:00 作者:
晚上有朋友問起,簡單的寫了一個(gè)。
復(fù)制代碼 代碼如下:
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 ;
調(diào)用方法示例:
復(fù)制代碼 代碼如下:
select func_rand_string(12,3);
相關(guān)文章
MySQL進(jìn)行大數(shù)據(jù)量分頁的優(yōu)化技巧分享
mysql大數(shù)據(jù)量分頁情況下性能會很差,所以本文就來講一講mysql大數(shù)據(jù)量下偏移量很大,性能很差的問題,并附上解決方式,希望對大家有所幫助2024-01-01
使用Mycat-eye管理Mycat數(shù)據(jù)庫服務(wù)的操作
MyCat是一個(gè)開源的分布式數(shù)據(jù)庫系統(tǒng),是一個(gè)實(shí)現(xiàn)了MySQL協(xié)議的服務(wù)器,前端用戶可以把它看作是一個(gè)數(shù)據(jù)庫代理,用MySQL客戶端工具和命令行訪問,本文給大家介紹了使用Mycat-eye管理Mycat數(shù)據(jù)庫服務(wù)的操作,需要的朋友可以參考下2024-04-04
詳解如何通過Mysql的二進(jìn)制日志恢復(fù)數(shù)據(jù)庫數(shù)據(jù)
本篇文章主要介紹了詳解如何通過Mysql的二進(jìn)制日志恢復(fù)數(shù)據(jù)庫數(shù)據(jù),具有一定的參考價(jià)值,有興趣的可以了解一下。2017-04-04
MySQL從一個(gè)表中查出數(shù)據(jù)并插入到另一個(gè)表的詳細(xì)處理方案
這篇文章主要給大家介紹了關(guān)于MySQL從一個(gè)表中查出數(shù)據(jù)并插入到另一個(gè)表的詳細(xì)處理方案,文中通過圖文介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用MySQL具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-12-12
MySQL錯(cuò)誤“Specified key was too long; max key length is 1000 b
今天在為數(shù)據(jù)庫中的某兩個(gè)字段設(shè)置unique索引的時(shí)候,出現(xiàn)了Specified key was too long; max key length is 1000 bytes錯(cuò)誤2010-08-08
CentOS7.x卸載與安裝MySQL5.7的操作過程及編碼格式的修改方法
這篇文章主要介紹了CentOS7.x卸載與安裝MySQL5.7的操作過程及編碼格式的修改方法,本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05

