当前位置:网站首页>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;
边栏推荐
- How MySQL uses JSON_ Extract() takes JSON value
- Error in compiling libssh2. OpenSSL cannot be found
- Flask solves the problem of CORS err
- Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
- ThoughtWorks global CTO: build the architecture according to needs, and excessive engineering will only "waste people and money"
- Embedded-c Language-4
- CMake教程Step3(添加库的使用要求)
- 漫画:寻找无序数组的第k大元素(修订版)
- Rider set the highlighted side of the selected word, remove the warning and suggest highlighting
- 普通程序员看代码,顶级程序员看趋势
猜你喜欢
Design of electronic clock based on 51 single chip microcomputer
MySQL queries the latest qualified data rows
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
[Web attack and Defense] WAF detection technology map
Judge whether a number is a prime number (prime number)
Kafaka technology lesson 1
基于Redis实现延时队列的优化方案小结
mysql中取出json字段的小技巧
Rider set the highlighted side of the selected word, remove the warning and suggest highlighting
Embedded -arm (bare board development) -2
随机推荐
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
Rider 设置选中单词侧边高亮,去除警告建议高亮
漫画:有趣的【海盗】问题
c#图文混合,以二进制方式写入数据库
The second day of learning C language for Asian people
7.Scala类
Flow characteristics of kitchen knife, ant sword, ice scorpion and Godzilla
查看自己电脑连接过的WiFi密码
机器学习01:绪论
云主机oracle异常恢复----惜分飞
Tips for extracting JSON fields from MySQL
Cartoon: interesting [pirate] question
漫画:寻找无序数组的第k大元素(修订版)
MySql 查询符合条件的最新数据行
C # realizes crystal report binding data and printing 3-qr code barcode
MySQL queries the latest qualified data rows
菜刀,蚁剑,冰蝎,哥斯拉的流量特征
Embedded-c Language-1
CVPR 2022最佳学生论文:单张图像估计物体在3D空间中的位姿估计
Ordinary programmers look at the code, and top programmers look at the trend