The eighth chapter of Mysql [commonly used functions]
Others
2020-04-18 23:03:58
views: null
Numeric function
Function name |
Work |
abs |
Find the absolute value |
sqrt |
Find the square root |
mod |
Find the remainder |
ceil 和 ceiling |
Both functions have the same function, both return the smallest integer that is not less than the parameter, ie round up |
floor |
Round down, the return value is converted into a BIGINT |
rand |
Generate a random number between 0 and 1, the integer parameter is used to generate a repeating sequence |
round |
Round off the passed parameters |
sign |
Return the symbol of the parameter |
pow and power |
Both functions have the same function and are the result of the power of the passed parameter |
without |
Find the sine value |
asin |
Find the inverse sine value and inverse function with the function SIN |
cos |
Find the cosine |
acos |
Find the inverse cosine value and inverse function with the function COS |
tan |
Find the tangent |
assign |
Find the arc tangent value, which is an inverse function with the function TAN |
cot |
Find the cotangent |
String functions
Function name |
Work |
length |
Calculate string length function, return the length of the string in bytes |
concat |
Combine string functions, return the result is the string generated by the connection parameters |
insert |
Replace string function |
lower |
Convert letters in string to lower case |
upper |
Convert letters in a string to uppercase |
left |
Truncate the character string from the left word and return several characters to the left of the string |
right |
Intercept the character string from the right word and return several characters to the right of the string |
trim |
Delete the spaces on the left and right of the string |
replace |
String replacement function, returns the new string after replacement |
substr 和 substring |
Truncate the string, return the specified length of characters starting from the specified position |
reverse |
String reversal (reverse order) function, returns the string in reverse order from the original string |
Date and time functions
Function name |
Work |
curdate 和 current_date |
Both functions have the same effect, returning the date value of the current system |
curtime 和 current_time |
Both functions have the same effect and return the current system time value |
now 和 sysdate |
Both functions have the same effect, returning the date and time values of the current system |
unix_timestamp |
Get UNIX timestamp function, returns an unsigned integer based on UNIX timestamp |
from_unixtime |
Convert UNIX timestamp to time format, inverse function with UNIX_TIMESTAMP |
month |
Get the month in the specified date |
monthname |
获取指定日期中的月份英文名称 |
dayname |
获取指定曰期对应的星期几的英文名称 |
dayofweek |
获取指定日期是一周中是第几天,返回值范围是1~7,1=周日 |
week |
获取指定日期是一年中的第几周,返回值的范围是否为 0〜52 或 1〜53 |
dayofyear |
获取指定曰期是一年中的第几天,返回值范围是1~366 |
dayofmonth |
获取指定日期是一个月中是第几天,返回值范围是1~31 |
year |
获取年份,返回值范围是 1970〜2069 |
time_to_sec |
将时间参数转换为秒数 |
sec_to_time |
将秒数转换为时间,与TIME_TO_SEC 互为反函数 |
date_add 和 adddate |
两个函数功能相同,都是向日期添加指定的时间间隔 |
date_sub 和 subdate |
两个函数功能相同,都是向日期减去指定的时间间隔 |
addtime |
时间加法运算,在原始时间上添加指定的时间 |
subtime |
时间减法运算,在原始时间上减去指定的时间 |
datediff |
获取两个日期之间间隔,返回参数 1 减去参数 2 的值 |
date_format |
格式化指定的日期,根据参数返回指定格式的值 |
weekday |
获取指定日期在一周内的对应的工作日索引 |
流程控制函数
函数名称 |
作用 |
if |
判断,流程控制 |
ifnull |
判断是否为空 |
case |
搜索语句 |
聚合函数
函数名称 |
作用 |
max |
查询指定列的最大值 |
min |
查询指定列的最小值 |
count |
统计查询结果的行数 |
sum |
求和,返回指定列的总和 |
avg |
求平均值,返回指定列数据的平均值 |
其它函数
函数名称 |
作用 |
version |
数据库版本号 |
database |
当前的数据库 |
user |
当前连接用户 |
md5 |
返回字符串的md5数据 |
Origin www.cnblogs.com/kwdlh/p/12728772.html