当前位置:网站首页>9. Common functions
9. Common functions
2022-04-23 07:40:00 【Ah Dai cloth clothes cool】
9. Common functions
One : String function
1. String concatenation
select concat(' The number is ',empno,' The employees' , The name is ',ename) from emp;
2. Change the string to lowercase
select lower('Hello') from dual
3. Change the string to uppercase
select upper('Hello') from dual;
4. Get string length
select length('hello') from dual;
5. Invert string
select reverse('hello') from dual;
6. Remove the spaces on both sides of the string
select trim(' hello ') from dual;
7. The string s Medium s1 Replace with s2
select replace('hello world','o','xx') from dual
8. The string s repeat n Go back to
select repeat('hello',3) from dual
9. In string s Use... On the left of the s1 Fill in , Until the length is len
select lpad('hello',8,'x') from dual;
10. character string s Use... On the right of s1 Fill in , Until the length is len
select rpad('hello',8,'x') from dual;
11. From i String starting at s Intercept , Intercept len individual
select substr('hello',2,3) from dual;
Two : Numerical function
1. Return is greater than the n Minimum integer of
select ceil(10.1) from dual;
2. Back to less than n Maximum integer for
select floor(10.1) from dual;
3. take n Retain y Decimal place , rounding
select round(3.1415.3) from dual;
4. take n Retain y Decimal place , Do not round off
select truncate(3.1415,3) from dual;
5. return 0 To 1 The random number
select rand() from dual;
3、 ... and : Date and time functions
1. Returns the current date time
select now() from dual;
2. Return current date
select curdate() from dual;
3. Return current time
select curtime from dual;
4. Returns the year in the date
select year('2018-2-14') from dual;
5. Returns the month in the date
select month('2018-2-14') from dual;
6. Returns the day of the date
select day('2018-2-14') from dual;
7. Returns the integer between two dates and times
select timestampdiff(day,'1993-9-23','2018-11-22') from dual;
8. Format date
select date_format(now(),'%Y year %m month %d Japan %H:%i:%s') from dual;
Four : Process control functions
1.if(f,v1,v2) If f It's true , Then return to v1, Otherwise return to v2
select if(5>2,'yes','no') from dual;
2.ifnull(v1,v2) If v2 Not for null, Then return to v1, Otherwise return to v2
select ifnull(null,'0') from dual
3.case when f1 then v1 when f2 then v2…else v end If f1 It's true , Then return to v1; If f2 It's true , Then return to v2… Otherwise return to v
select case when 5<2 then 'one' when 6>4 then 'two'
else 'three' end
from dual;
5、 ... and : System information function
1. Returns the database of the current operation
select database();
2. Return the currently logged in user
select user();
3. return MySQL Server version
select version();
版权声明
本文为[Ah Dai cloth clothes cool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622239265.html
边栏推荐
- USO technology was invited to share the technical framework and challenges of AI synthetic virtual characters at lvson2020 conference
- 刨根问底---cocos2d源码的理解与分析
- 数论分块(整除分块)
- 基于可视化结构的身份证号码校验系统-树莓派实现
- 【自我激励系列】你永远不会准备好
- C语言的指针符号到底靠近变量类型还是变量名?
- 简单易懂的子集dp
- 10.更新操作
- On BFC (block formatting context)
- 数据分析入门 | kaggle泰坦尼克任务(三)—>探索数据分析
猜你喜欢
Visualization Road (IX) detailed explanation of arrow class
Django使用mysql数据库报错解决
Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet
USO technology was invited to share the technical framework and challenges of AI synthetic virtual characters at lvson2020 conference
数论分块(整除分块)
页面实时显示当前时间
manjaro安装与配置(vscode,微信,美化,输入法)
ogldev-读书笔记
[COCI]Lampice (二分+树分治+字符串哈希)
keytool: command not found
随机推荐
2022.3.14 阿里笔试
Solutions to common problems in visualization (VII) solutions to drawing scale setting
状态同步与帧同步
Django使用mysql数据库报错解决
9.常用函数
# 可视化常见绘图(二)折线图
开发板如何ping通百度
2.限定查询
两个线程交互打印奇偶数字
What is a closure?
LATEX公式注意事项
青龙面板拉库命令更新【2022/4/20】收藏不走丢
快速下载vscode的方法
Us photo cloud editing helps BiliBili upgrade its experience
常用的DOS命令
(扩展)BSGS与高次同余方程
ESP32学习-向工程项目添加文件夹
[ACM-ICPC 2018 沈阳赛区网络预赛] J.Ka Chang (分块+dfs序)
VScode
On BFC (block formatting context)