-
算术函数
-
ABS--绝对值
abs(数值)
select m,abs (m) as abs_col from 表名;
-
mod--求余
mod(被余数,除数)
-
round--四舍五入
round(对象,保留的小数的位数)
-
字符串函数
-
||--拼接
str1 || str2
在mysql中是concat(字符串,字符串,字符串)
-
length()--字符串的长度
-
lower()--小写转换
-
upper()--大写转换
-
replace(用来替换的字符串,替换前的字符串,替换后的字符串)--字符串的替换
-
substring(用来截取的字符串 from 开始的截取的字节 for 截取多少字节)--字符串截取
-
日期函数
-
current_date--当前日期
select current_date;
-
current_time--当前时间
select current_time;
-
current_timestamp--当前日期和时间
select current_timestamp;
-
extract(日期元素 from 日期)--截取日期元素
extract (year from current_timestamp) as year;
-
转换函数
-
cast(转换前的值 as 想要转换的数据类型)--类型转换
select cast('0001' as integer) as int_col;
结果为1
-
coalesce(数据1,数据2,数据3,……)--将NULL转换为其他值