mysql函數

Mysql函數

加密密碼
select password(‘123456’);
md5加密密碼(貌似mysql數據庫相同密碼每次加密後的md5字符串都是一樣)
select md5(‘123456’);

select AES_ENCRYPT(‘123456’,’key’) ; #加密
select AES_DECRYPT( ( select AES_ENCRYPT(‘123456’,’key’) ),’key’) ; #解密

select encode(‘123456’,’qwedgnkh’); #加密
select decode(encode (“‘123456’”,“‘qwedgnkh’”),“‘qwedgnkh’”) #解密

select charset(‘string’),charset(convert(‘string’ using latin1)); #改變字串的默認字符集

使用數學函數rand()生成3個10以內的隨機整數
select round(rand() * 10) , round(rand() * 10) , round(rand() * 10) ;

使用函數計算三角函數
select pi() ,sin( pi()/2 ) ,cos( pi() ),round( tan(pi()/4) ),floor( cot(pi()/4) );

獲得當前日期+時間(date + time)函數:now()
select now() ;

獲得當前時間戳函數
select current_timestamp();

函數:date_format(date,format), time_format(time,format)
select date_format(‘2008-08-08 22:23:01’,’%Y%m%d%H%i%s’);
select time_format(‘2008-08-08 22:23:01’,’%Y%m%d%H%i%s’);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章