深入淺出MySQL筆記(三)

2021-08-08 23:17:24 字數 1840 閱讀 4885

本筆記為學習該書所記,便於複習。

包含第五、六章筆記。

常用函式與圖形化工具的使用。

[toc]

常用字串函式

concat(s1,s2...sn)          ##連線s1,s2...sn為乙個字串

insert(str,x,y,instr) ##將字串str從第x位置開始,y個字元長的子串替換為字串instr

lower(str) ##將字串str中所有字元變為小寫

upper(str) ##將字串str中所有字元變為大寫

left(str,x) ##返回字串str最左邊的x個字元

right(str,x) ##返回字串str最右邊的x個字元

lpad(str,n,pad) ##用字串pad對str最左邊進行填充,直到長度為n個字元長度

rpad(str,n,pad) ##用字串pad對str最右邊進行填充,直到長度為n個字元長度

ltrim(str) ##去掉字串str左側的空格

rtrim(str) ##去掉字串str右側的空格

repeat(str,x) ##返回str重複x次的結果

replace(str,a,b) ##用字串b替換字串str中所有出現的字串a

strcmp(s1,s2) ##比較字串s1和s2

trim(str) ##去掉字串行尾和行頭的空格

substring(str,x,y) ##返回從字串str x位置起y個字元長度的字串

常用數值函式

abs(x)                   ##返回x的絕對值

ceil(x) ##返回大於x的最小整數值

floor(x) ##返回小於x的最大整數值

mod(x,y) ##返回x/y的模

rand() ##返回0~1內的隨機值

round(x,y) ##返回引數x的四捨五入的有y位小數的值

truncate(x,y) ##返回數字x截斷為y位小數的結果

常用時間和日期函式

if(value,t,f)

##如果value是真,返回t;否則返回f

ifnull(value1,value2)

##如果value1不為空,返回value1,否則返回value2

case wher [value1] then [result1]...eles [default] end

##如果value1是真,返回result1,否則返回default

case [expr] when [value1] then [result1]... else [default] end

##如果expr等於value1,返回result1,否則返回default

database()

version()

user()

inet_aton(ip)

inet_ntoa(num)

password(str)

md5()

深入淺出MySQL

說明索引的設計和使用 sql中的安全問題 常用sql技巧 sql優化過程 優化資料庫物件 鎖問題 本站 深入淺出mysql 個人部落格 深入淺出mysql 1 設計索引原則 2 小常識 3 btree索引 1 了解sql執行頻率 使用show session global statusa來獲得伺服器...

《深入淺出MFC》筆記(三)

1,win32 console程式示例 include include include include const int filemax 300 allow max.300 files in each directory typedef struct destfile destfile typed...

深入淺出MySQL筆記(二)

本筆記為學習該書所記,便於複習。包含第三 四章筆記。資料型別與運算子 toc 整數型別 zerofill unsigned auto increment 浮點數型別 定點數型別 decimal m,d show warningsl 位型別bit m hex data datatime timesta...