当前位置:网站首页>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;
边栏推荐
- Embedded-c Language-1
- MYSQL group by 有哪些注意事项
- In depth understanding of redis memory obsolescence strategy
- Example tutorial of SQL deduplication
- Embedded-c Language-3
- The second day of learning C language for Asian people
- 深入理解Redis内存淘汰策略
- The five most difficult programming languages in the world
- 哈趣K1和哈趣H1哪个性价比更高?谁更值得入手?
- Rider set the highlighted side of the selected word, remove the warning and suggest highlighting
猜你喜欢
ICML 2022 | Meta propose une méthode robuste d'optimisation bayésienne Multi - objectifs pour faire face efficacement au bruit d'entrée
Redis+caffeine two-level cache enables smooth access speed
Complete solution instance of Oracle shrink table space
CVPR 2022最佳学生论文:单张图像估计物体在3D空间中的位姿估计
查看自己电脑连接过的WiFi密码
MySQL之知识点(六)
Using C language to realize palindrome number
The second day of learning C language for Asian people
一文了解MySQL事务隔离级别
Machine learning 02: model evaluation
随机推荐
Embedded UC (UNIX System Advanced Programming) -3
域名解析,反向域名解析nbtstat
Tita 绩效宝:如何为年中考核做准备?
Cartoon: how to multiply large integers? (integrated version)
Judge whether a string is a full letter sentence
通过proc接口调试内核代码
云安全日报220705:红帽PHP解释器发现执行任意代码漏洞,需要尽快升级
flask解决CORS ERR 问题
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
mysql中取出json字段的小技巧
Understand the usage of functions and methods in go language
Thoughtworks 全球CTO:按需求构建架构,过度工程只会“劳民伤财”
thinkphp模板的使用
Beijing internal promotion | the machine learning group of Microsoft Research Asia recruits full-time researchers in nlp/ speech synthesis and other directions
Zhang Ping'an: accélérer l'innovation numérique dans le cloud et construire conjointement un écosystème industriel intelligent
机器学习01:绪论
【二叉树】根到叶路径上的不足节点
CMake教程Step3(添加库的使用要求)
Cartoon: how to multiply large integers? (next)
ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise