官网地址:https://dev.mysql.com/doc/refman/8.0/en/sql-replication-statements.html
常用函数
-- 数学运算
select abs(*) -- *的绝对值
select ceiling(*) -- 向上取整
select floor(*) -- 向下取整
select rand() -- 生成一个0~1之间的随机数
select sign(*) -- 判断一个数的正负,正数返回 1,负数返回 -1,0 返回 0
-- 字符串函数
select char_length('*') -- 返回字符串长度
select concat('*','*',...) -- 将字符串按顺序拼接在一起
select insert('*','起始位置','替换长度','*') -- 查询,并替换指定位置的指定长度
select lower('*') -- 全部转小写
select upper('*') -- 全部转大写
select insetr('*','字串') -- 返回第一次出现的子串的索引
select replace('*','指定字符串','*') -- 替换出现的指定字符串
select substr('*','起始位置','指定长度') -- 返回指定的子字符串
select reverse(`*`) -- 反转指定字符串
-- 时间和日期函数
select current_date() -- 获取当前日期
select curdate() -- 获取当前日期
select now() -- 获取当前时间
select looaltime() -- 获取本地时间
select sysdate() -- 获取系统时间
-- (now()可自行替换)
select year(now()) -- 获取当前时间的年份
select month(now()) -- 获取当前时间的月份
select day(now()) -- 获取当前时间的天数
select hour(now()) -- 获取当前时间的小时
select minute(now()) -- 获取当前时间的分钟
select second(now()) -- 获取当前时间的秒数
-- 系统函数
select system_user() -- 系统当前用户
select user() -- 系统当前用户
select version() -- 获取当前版本号
聚合函数
select count(`*`) -- 计数 (当*为指定字段时,会忽略所有的null值)(当*为*时,不会忽略null值)(当*为1时,不会忽略null值)
select sum(`*`,`*`,...) -- 求和
select avg(`*`,`*`,...) -- 平均值
select max(`*`,`*`,...) -- 最大值
select min(`*`,`*`,...) -- 最小值
MD5函数
update `表名` set `字段名` = md5(`字段名`)