当前位置:网站首页>mysql函数
mysql函数
2022-07-26 08:48:00 【我的天才女友】
数字函数
- abs() 绝对值函数
- ceil ceiling 大于或等于值的最小整数
- floor 小于或者等于值的最大整数
- least 返回参数中最小的值
- greatest 返回列表最大的值
- radians 角度转弧度
- degrees 弧度转角度
- sin / asin 正弦函数/ 反正弦函数 参数是弧度
- cos / acos 余弦 / 反余弦
- tan / atan 正切 / 反正切
- atan2(m,n) 返回两个参数的反正切值
- cot 余切
- pow / power乘方
- exp e的x次方
- sqrt 参数的平方根
- ln / log e为底的x的对数
- log10 10为底的参数的对数
- log2 2为底的参数的对数
- rand 随机返回0到1之间的随机数
- rand(x) 参数一致返回的随机数一样
- round 四舍五入的整数
- round(x,y) y表示保留的小数位
- truncate(x,y) y表示保留的位数相对于小数位
- sign 符号函数,正数返回1,否则0
- div 除
- mod 返回余数
字符串函数
- ascii 返回参数的第一个ascii码值
- char_length 返回参数的字符个数
- length 返回参数的长度
- concat 结合参数返回一个字符,其中有一个是NULL,返回NULL
- concat_ws 返回以第一个参数分割结合的字符,如果第一个参数是NULL,则返回null,其余参数为null则忽略
- insert(oldstr,x,y,replacestr) 字符oldstr的从x位置y个字符的长度的字符替换为replacestr
- lower / upper 大小写转化
- left(str,x) / right(str,x) 返回左右特定个数字符
- lpad(str,n,pstr) / rpad(str,n,pstr) 对字符串str 左右进行填充直至长度到n
- ltrim / rtrim / trim 去除字符左右空格
- trim(substr from str) 去除str中左右的substr
- repeat(str,x) 重复str字符x次
- replace(s,a,b) 用b替换在s中的a
- strcmp(s1,s2) 比较s1和s2的ascii的码值大小,返回-1、0和1
- substr(s,x,y) / substring(s,x,y) / mid(s,x,y) 想当与裁剪字符s从x位置开始的y个字符
- space 返回参数个空格的空格字符
- locate(substr, str) / position(substr, str) / instr(substr, str) 返回字符串substr在str的位置
- elt(m,s1,s2…) 返回m值对应之后的字符的位置
- field(s,s1,s2…) 返回第一个参数出现在后的字符列表中
- find_in_set(s1,s2) 返回s1在字符s2中出现的位置
- reverse 返回s字符相反的字符串
- nullif(s1,s2) 如果s1和s2相等,则返回null,否则返回s1
日期和时间函数
utc指的是世界协调时间
- curdate 当前日期,格式为YYYY-MM-DD
- curtime 当前事件,格式为HH:MM:SS
- now 当前时间和日期,格式为YYYY-MM-DD HH:MM:SS
- unix_timestamp 将参数日期转化为unix时间戳
- from_unixtime 将参数unix时间戳转化为日期
- utc_date 返回utc日期
- utc_time 返回utc时间
- year month 返回参数所在日期的年份、月份
- monthname 返回参数所在日期的月份的英文名称
- day 返回参数的日期
- dayofweek 返回参数中天数对应的周中的天数
- weekday 返回参数中天数对应的周中的天数索引值,0对应中周一
- week 当前日期对应年中的周
- weekofyear 当前日期对应年中的周
- dayofyear 对应一年中的天数
- dayofmonth 对应一天在月中的天数
- quarter 当前季节
- hour minute second 参数对应的小时、分钟和秒数
- extract(type from date) 从日期中返回特定的部分
- time_to_sec 将time转化为秒
- sec_to_time 将秒转化为time
- date_add(date interval expr type) / date_sub(date interval expr type) 日期加减运算
- addtime / subtime 日期相加减, 第二个参数为秒
- datediff 计算日期之间的相差的天数
- from_days() 从0000年1月1日参数之后的日子
- last_day 当前月份的最后一天
- makedate / maketime 组合时间和日期
- period_add(time.n) 时间加上n后
- to_days() 距离0000年1月1日到参数的日子
- date_format(date, format) / time_format(date, format) 按照指定的格式format 日期
- get_format(date_type, format_type) 返回日期字符串格式
- str_to_date(str, format) 返回str按照format格式转化为的日期或时间
流程处理函数
- if(v1,v2,v3) 如果v1为true,返回v2,否则返回v3
- ifnull(v1,v2) 如果v1不为null,返回v1,否则返回v2
- case when codition then
- case v1 when v2 then
加密和解密函数
- password 加密
- md5 对value进行md5加密
- encode / decode 使用对应的值进行加密和解密
聚合函数
- count 计数
- max 最大
- min 最小
- sum 求和
- avg 球平均值
获取mysql信息函数
- version 版本号
- datebase 当前命令所在数据库
- user 当前用户
- last_insert_id 自增的最新值
- charset(value) mysql字符集
- collation(value) 字符串排序方式
加锁与解锁函数
- get_lock(v1,timeout) 获取v1的锁,持续timeout
- release_lock 解除锁
- is_ferr_lock 判断差数的锁是否可以使用
- is_used_lock 判断差数的锁是否正在使用
JSON函数
- json_contains 查询json是否包含特定的值
- json_search 在json字段指定的key中找value
- json_pretty 以优雅的格式显示json
- json_depth 查询json的深度
- json_length json数据的长度
- json_keys 返回json数据顶层key组成的json数据
- json_insert 在json中插入数据
- json_remove 移除json中指定key的值
- json_replace 更新json中指定key的值
- json_set 向json中插入数据
- json_type 用于返回json数据的类型
- json_valid 判断value是否是有效的json数据
窗口函数
- row_number 顺序排序
- rank 并列排序,通过重复的序号
- dense_rank 并列排序
- percent_rank 等级百分比
- cume_dist 累计分布值
- lag(expr, n) 返回当前行的前n行的expr的值
- lead(expr, n) 返回当前行的后n行的expr的值
- first_value(expr) /last_value 返回第一个或者最后一个expr的值
- nth_value(expr,n) 返回第n个expr的值
- ntile 将分区的有序数据分为n个桶,记录桶编号
其他函数
format(value,n) 四舍五入,n表示小数位数
conv(value, from, to) 进制转化
inet_aton 将ip转化为数字
inet_ntoa 将数字转化为ip地址
benchmark 测试mysql处理参数处理的所耗费的时间
cast 将value转化为type类型
convert 将value所使用的字符编码转化为char_code
边栏推荐
- JS file import of node
- node的js文件引入
- Cve-2021-3156 duplicate of sudo heap overflow privilege raising vulnerability
- One click deployment of lamp and LNMP scripts is worth having
- Ueditot_ JSP SSRF vulnerability recurrence
- 【数据库 】GBase 8a MPP Cluster V95 安装和卸载
- [freeswitch development practice] user defined module creation and use
- Web概述和B/S架构
- Cadence(十)走线技巧与注意事项
- Registration of finite element learning knowledge points
猜你喜欢

Xshell batch send command to multiple sessions
![[encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week

Database operation topic 1

day06 作业--技能题2

One click deployment of lamp and LNMP scripts is worth having

Regular expression: judge whether it conforms to USD format

TCP solves the problem of short write
![[database] gbase 8A MPP cluster v95 installation and uninstall](/img/56/c0dae30ba608842c1b92e914ef42fe.png)
[database] gbase 8A MPP cluster v95 installation and uninstall

Human computer interaction software based on C language

The idea shortcut key ALT realizes the whole column operation
随机推荐
Typescript encryption tool passwordencoder
Espressif 玩转 编译环境
Use index to optimize SQL query "suggestions collection"
SSH,NFS,FTP
数据库操作技能7
Day06 homework -- skill question 1
Set of pl/sql
Oracle 19C OCP 1z0-083 question bank (7-12)
Pytoch learning - from tensor to LR
My meeting of OA project (query)
Pytoch realizes logistic regression
[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls
JDBC database connection pool (Druid Technology)
[abstract base class inheritance, DOM, event - learning summary]
海内外媒体宣发自媒体发稿要严格把握内容关
03异常处理,状态保持,请求钩子---04大型项目结构与蓝图
Replication of SQL injection vulnerability in the foreground of Pan micro e-cology8
Learning notes of automatic control principle - Performance Analysis of continuous time system
Web overview and b/s architecture
数据库操作 题目一