当前位置:网站首页>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;

边栏推荐
- Cartoon: interesting pirate problem (full version)
- Winedt common shortcut key modify shortcut key latex compile button
- Read the basic grammar of C language in one article
- Mysql5.6 parsing JSON strings (supporting complex nested formats)
- ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise
- First day of learning C language
- 力扣解法汇总729-我的日程安排表 I
- High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
- Embedded -arm (bare board development) -1
- Error in compiling libssh2. OpenSSL cannot be found
猜你喜欢

ICML 2022 | Meta提出魯棒的多目標貝葉斯優化方法,有效應對輸入噪聲

Use of ThinkPHP template

查看自己电脑连接过的WiFi密码

Embedded -arm (bare board development) -2
MySql 查询符合条件的最新数据行

thinkphp模板的使用

Rider set the highlighted side of the selected word, remove the warning and suggest highlighting

Embedded UC (UNIX System Advanced Programming) -3
Database design in multi tenant mode

Machine learning 02: model evaluation
随机推荐
Debug kernel code through proc interface
Cartoon: how to multiply large integers? (integrated version)
一个满分的项目文档是如何书写的|得物技术
Ordinary programmers look at the code, and top programmers look at the trend
机器学习02:模型评估
漫画:如何实现大整数相乘?(整合版)
漫画:如何实现大整数相乘?(下)
Cartoon: looking for the k-th element of an unordered array (Revised)
ClickHouse(03)ClickHouse怎么安装和部署
BigDecimal除法的精度问题
Kafaka技术第一课
Domain name resolution, reverse domain name resolution nbtstat
mysql如何使用JSON_EXTRACT()取json值
排错-关于clion not found visual studio 的问题
漫画:如何实现大整数相乘?(上) 修订版
北京内推 | 微软亚洲研究院机器学习组招聘NLP/语音合成等方向全职研究员
Redis+caffeine two-level cache enables smooth access speed
Oracle缩表空间的完整解决实例
IDC报告:腾讯云数据库稳居关系型数据库市场TOP 2!
世界上最难的5种编程语言