当前位置:网站首页>MySQL之知识点(六)
MySQL之知识点(六)
2022-07-05 16:57:00 【flag:卷王!】
一、数值函数
1,基本函数
演示效果:
代码:select abs(-12),sign(-23),sign(43),pi(),ceil(32.32),ceiling(-32.32),floor(43.43),floor(-43.43),mod(12,5) from dual;
四舍五入:
mysql> select round(123,456),round(123.456,0),round(123.456,1),round(123.456,-1) from dual;
截断操作:(无论是什么,都不要)
mysql> select truncate(123.456,0),truncate(123.456,1),truncate(129.45,-1) from dual;
2,三角函数
其中角度与弧度互换函数:
mysql> select radians(30),radians(45) from dual;
mysql> select degrees(2*pi()) from dual;(注意PI后面必须截有括号)
三角函数:
mysql> select sin(radians(30)),asin(0.5),degrees(asin(0.5)),tan(radians(45)) from dual;
3,指数与对数
对数:
mysql> select pow(2,5),power(2,4),exp(2) from dual;
指数(默认是e):
mysql> select ln(exp(2)),log(exp(2)),log10(10),log2(4) from dual;
4,进制间的转换
mysql> select bin(10),hex(10),oct(10),conv(10,10,8) from dual;
二、字符串函数
需要注意的是:
在字符串索引是从1开始的:
mysql> select insert('hellowworld',2,3,'aaaaa'),replace('helloword','l','mmm') from dual;
三、日期与时间函数
1,获取日期、时间的
获取日期与时间:
mysql> select curdate(),current_date(),curtime(),now(),sysdate(),utc_date(),utc_time() from dual;
2,日期与时间戳的转化
mysql> select unix_timestamp(),unix_timestamp('2022-7-04 12:12:30') from dual;
3,获取月份、星期、星期数、天数等函数
mysql> select year(curdate()),month(curdate()),day(curdate()),hour(curtime()),minute(now()),second(sysdate()) from dual;
4,日期的操作函数
mysql> select extract(second from now()),extract(month from now()) from dual;
5,时间与秒钟转换的函数
mysql> select time_to_sec(curtime()),sec_to_time(45880) from dual;
6,计算日期与时间的函数
第一组:
select now(), date_add(now(),interval 1 year), date_add(now(),interval -1 year),date_sub(now(),interval 1 year) from dual;
第二组:
5,日期的格式化和解析
格式化:日期---->字符串
解析:字符串---->日期
格式化(根据不同情况来确定大小写):
mysql> select date_format(curdate(),'%y-%m-%d'),date_format(now(),'%y-%m-%d') from dual;
mysql> select date_format(curdate(),'%Y-%m-%d'),date_format(now(),'%Y-%m-%d') from dual;
解析:(格式化的逆过程):
mysql> select str_to_date('2022-October-24th 11:34:42 Monday 1 ','%Y-%M-%D %h:%i:%S %W %w ') from dual;
边栏推荐
- 一口气读懂 IT发展史
- C language to get program running time
- [first lecture on robot coordinate system]
- Deeply cultivate 5g, and smart core continues to promote 5g applications
- The first lesson of EasyX learning
- Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
- CMake教程Step3(添加库的使用要求)
- 【二叉树】根到叶路径上的不足节点
- What are the precautions for MySQL group by
- thinkphp模板的使用
猜你喜欢
The first EMQ in China joined Amazon cloud technology's "startup acceleration - global partner network program"
Summary of optimization scheme for implementing delay queue based on redis
Complete solution instance of Oracle shrink table space
ternary operator
Kafaka技术第一课
SQL删除重复数据的实例教程
腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
Machine learning compilation lesson 2: tensor program abstraction
33:第三章:开发通行证服务:16:使用Redis缓存用户信息;(以减轻数据库的压力)
Embedded UC (UNIX System Advanced Programming) -2
随机推荐
世界上最难的5种编程语言
【testlink】TestLink1.9.18常见问题解决方法
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
Read the basic grammar of C language in one article
C#实现水晶报表绑定数据并实现打印3-二维码条形码
How MySQL uses JSON_ Extract() takes JSON value
CVPR 2022最佳学生论文:单张图像估计物体在3D空间中的位姿估计
【二叉树】根到叶路径上的不足节点
【7.7直播预告】《SaaS云原生应用典型架构》大咖讲师教你轻松构建云原生SaaS化应用,难题一一击破,更有华为周边好礼等你领!
What else do you not know about new map()
Use of ThinkPHP template
查看自己电脑连接过的WiFi密码
[wechat applet] read the life cycle and route jump of the applet
2022 年 Q2 加密市场投融资报告:GameFi 成为投资关键词
一口气读懂 IT发展史
域名解析,反向域名解析nbtstat
力扣解法汇总1200-最小绝对差
stirring! 2022 open atom global open source summit registration is hot!
Machine learning 01: Introduction
Is it safe to open an account for digging wealth stocks? How is it safe to open a stock account?