当前位置:网站首页>Knowledge points of MySQL (6)
Knowledge points of MySQL (6)
2022-07-05 17:31:00 【Flag: roll king!】
One 、 Numerical function
1, Basic functions

Demonstration effect :
Code :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;

rounding :
mysql> select round(123,456),round(123.456,0),round(123.456,1),round(123.456,-1) from dual;
Truncation operation :( Whatever it is , Not at all )
mysql> select truncate(123.456,0),truncate(123.456,1),truncate(129.45,-1) from dual;


2, Trigonometric functions

Where angle and radian exchange function :
mysql> select radians(30),radians(45) from dual;
mysql> select degrees(2*pi()) from dual;( Be careful PI Must be followed by parentheses )

Trigonometric functions :
mysql> select sin(radians(30)),asin(0.5),degrees(asin(0.5)),tan(radians(45)) from dual;

3, Exponents and logarithms
logarithm :
mysql> select pow(2,5),power(2,4),exp(2) from dual;
Index ( The default is e):
mysql> select ln(exp(2)),log(exp(2)),log10(10),log2(4) from dual;

4, Conversion between bases

mysql> select bin(10),hex(10),oct(10),conv(10,10,8) from dual;

Two 、 String function

It should be noted that :
When the string index is from 1 At the beginning :
mysql> select insert('hellowworld',2,3,'aaaaa'),replace('helloword','l','mmm') from dual;

3、 ... and 、 Date and time functions
1, Get date 、 The time of the

Get date and time :
mysql> select curdate(),current_date(),curtime(),now(),sysdate(),utc_date(),utc_time() from dual;

2, Date and timestamp conversion

mysql> select unix_timestamp(),unix_timestamp('2022-7-04 12:12:30') from dual;

3, Get month 、 week 、 Weeks 、 Functions such as days

mysql> select year(curdate()),month(curdate()),day(curdate()),hour(curtime()),minute(now()),second(sysdate()) from dual;

4, Operation function of date

mysql> select extract(second from now()),extract(month from now()) from dual;

5, Time and second conversion function

mysql> select time_to_sec(curtime()),sec_to_time(45880) from dual;

6, Function for calculating date and time
The first group :

select now(), date_add(now(),interval 1 year), date_add(now(),interval -1 year),date_sub(now(),interval 1 year) from dual;

The second group :

5, Formatting and parsing of dates
format : date ----> character string
analysis : character string ----> date



format ( Determine the case according to different situations ):
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;

analysis :( The reverse of formatting ):
mysql> select str_to_date('2022-October-24th 11:34:42 Monday 1 ','%Y-%M-%D %h:%i:%S %W %w ') from dual;

边栏推荐
- The five most difficult programming languages in the world
- thinkphp模板的使用
- Cmake tutorial step6 (add custom commands and generate files)
- Rider set the highlighted side of the selected word, remove the warning and suggest highlighting
- Independent development is a way out for programmers
- CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
- BigDecimal除法的精度问题
- flask解决CORS ERR 问题
- 【7.7直播预告】《SaaS云原生应用典型架构》大咖讲师教你轻松构建云原生SaaS化应用,难题一一击破,更有华为周边好礼等你领!
- 深入理解Redis内存淘汰策略
猜你喜欢

mongodb(快速上手)(一)
Summary of optimization scheme for implementing delay queue based on redis

How to write a full score project document | acquisition technology

Embedded -arm (bare board development) -2

CVPR 2022最佳学生论文:单张图像估计物体在3D空间中的位姿估计

ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声

MySQL之知识点(七)

Use of ThinkPHP template

Which is more cost-effective, haqu K1 or haqu H1? Who is more worth starting with?

基于51单片机的电子时钟设计
随机推荐
In depth understanding of redis memory obsolescence strategy
Tita performance treasure: how to prepare for the mid year examination?
mysql5.6解析JSON字符串方式(支持复杂的嵌套格式)
winedt常用快捷键 修改快捷键latex编译按钮
thinkphp3.2.3
Debug kernel code through proc interface
ClickHouse(03)ClickHouse怎么安装和部署
Cartoon: a bloody case caused by a math problem
Check the WiFi password connected to your computer
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
mongodb(快速上手)(一)
Judge whether a number is a prime number (prime number)
MySQL queries the latest qualified data rows
机器学习02:模型评估
统计php程序运行时间及设置PHP最长运行时间
CMake教程Step2(添加库)
張平安:加快雲上數字創新,共建產業智慧生態
MySQL之知识点(六)
漫画:有趣的【海盗】问题
MYSQL group by 有哪些注意事项