当前位置:网站首页>Oracle one line function Encyclopedia
Oracle one line function Encyclopedia
2022-06-25 08:53:00 【Mr. Li, a prodigy】
If a worker wants to do a good job, he must sharpen his tools first
Articles are constantly updated , You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .
List of articles
- One 、 String function
- 1、 Look up the student's name and capitalize
- 2、 Look up the student's name in lowercase
- 3、 take "helloword" title case
- 4、 Check all student names and capitalize
- 5、 Check the names of all students , And display the length of the name
- 6、 Check the names of all students , And will “ Zhang San ” Change it to “ Li Si ”
- 7、 take "hello word" Remove the space in
- 9、 Find out the last names of all students
- Two 、 Numerical function
- 3、 ... and 、 Date function
- Four 、 Conversion function
- 5、 ... and 、 The generic function
- 6、 ... and 、 summary
One 、 String function
Convert to uppercase function :upper
Convert to lowercase function :lower
The first letter becomes uppercase :initcap
Calculate string length :length
String substitution :replace( class , The value to replace , Replace with value )
String interception :substr( Column , The starting point , length )
1、 Look up the student's name and capitalize
select upper(name) from student;
2、 Look up the student's name in lowercase
select lower(name) from student;
3、 take "helloword" title case
Be careful dual yes oracle A self-contained watch
select initcap('helloword') from dual;
result :Helloword
4、 Check all student names and capitalize
Either of the following is OK
select initcap(name) from student;
5、 Check the names of all students , And display the length of the name
select name, length(name) from student;
6、 Check the names of all students , And will “ Zhang San ” Change it to “ Li Si ”
select replace(name,' Zhang San ',' Li Si ') from student;
7、 take "hello word" Remove the space in
select replace('hello word',' ','') from dual;
9、 Find out the last names of all students
Be careful , The initial character interception is from 1 At the beginning , If the initial value is written as 0 It will also default from 1 Start
select substr(name,1,1) from student;
Two 、 Numerical function
rounding :round( data , Keep decimal places )
Directly intercept decimal places , No rounding :trunc( data , Keep decimal places )
Modulus function :mod( Divisor , Divisor )
1、 take 123.4567 Keep two decimal places
select round(123.4567,2) from dual;
result :123.46
2、 take 123.4567 Keep the first two decimal places , Less than 5 Give up
select round(123.4567,-2) from dual;
result :100
3、 take -123.65 Integer
select round(-123.65) from dual;
result :-124
4、 take 123.4567 Cut directly to two decimal places
select trunc(123.4567) from dual;
result :123.45
5、 take -123.65 Directly truncate to an integer
select trunc(-123.65) from dual;
result :-123
6、 take 10 And 3 modulus
select mod(10,3) from dual;
result :1
3、 ... and 、 Date function
oracle The self-contained current date data column :sysdate
Calculate the month of difference between two dates :months_between( date 1, date 2)
Add a date after several months :add_months( date , Monthly number )
Query the last day of the month :last_day( date )
Calculate the next specified date :next_day( date , Time in a week )
1、 Query the current date
Be careful : The query here is oracle The date the database was installed on the computer , such as oracle Install on server , In this way, there will be a gap between the date when you use your local computer to remotely query the database and the date on your local computer , It's usually 1 About minutes .
select sysdate from dual;
2、 Query the date after three days
select sysdate + 3 from dual;
3、 Query the number of months between two dates
select months_between(date1,date2) from dual;
4、 Query the year difference between two dates
select trunc(months_between(date1,date2)/12) years from dual;
5、 Query the current date 5 Months later
select add_months(sysdate,5) from dual;
6、 Query the last day of the month
select last_day(sysdate) from dual;
7、 Check next Wednesday
select next_day(sysdate,' Wednesday ') from dual;
Four 、 Conversion function
Convert to string :to_char()
Convert to date :to_date()
Convert to number :to_number()
1、 Format the current date as yyyy-mm-dd Format string
select to_char(sysdate,'yyyy-mm-dd') from dual;
2、 Query the year of the current date
select to_char(sysdate,'yyyy') year from dual;
3、 take “1998-09-27” Convert to date format
select to_date('1998-09-27','yyyy-mm-dd') from dual;
4、 take “1” Convert to numeric format
select to_number('1') from dual;
5、 ... and 、 The generic function
If it is empty, the defined value is used , If it is not empty, the original value will be used :nvl( Column , Definition value )
Multi value judgment :decode( Column , Match content 1, According to the content 1, Match content 2, According to the content 2)
1、 Look up the names of the students , If the name is empty, use “ Zhang San ” Instead of
select nvl(name,' Zhang San ') from student;
2、 If the age of the student is blank, use 0 Instead of
select nvl(age,0) from student;
3、 Check the gender of the student , And will “ male ” Corresponding “man”, take “ Woman ” Corresponding “woman”
select decode(sex,' male ','man',' Woman ','woman') from student;
6、 ... and 、 summary
The relevant contents here have not been sorted out yet , The article continues to be updated later , Recommended collection .
The commands involved in the article must be typed several times each like me , Only in the process of knocking can you find out whether you really master the command .
You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .
边栏推荐
- [515. find the maximum value in each tree row]
- 自定义注解之编译时注解(RetentionPolicy.CLASS)
- How safe is the new bond
- View all listening events on the current page by browser
- C#程序终止问题CLR20R3解决方法
- 《乔布斯传》英文原著重点词汇笔记(六)【 chapter three 】
- Is it really safe to pay new debts? Is it risky
- Summary of NLP data enhancement methods
- socket编程——poll模型
- Advanced technology Er, meet internship position information
猜你喜欢
微信小程序_7,项目练习,本地生活
Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an
Lvs-dr mode multi segment case
How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
C#启动程序传递参数丢失双引号,如何解决?
Webgl Google prompt memory out of bounds (runtimeerror:memory access out of bounds, Firefox prompt index out of bounds)
LVS-DR模式单网段案例
View all listening events on the current page by browser
[515. find the maximum value in each tree row]
【515. 在每个树行中找最大值】
随机推荐
QSS buttons of different styles
云网络技术的好处以及类型
SharePoint:SharePoint Server 2013 与 ADRMS 集成指南
How to implement a system call
Advanced technology Er, meet internship position information
TrendMicro:Apex One Server 工具文件夹
C language "recursive series": recursive implementation of 1+2+3++ n
atguigu----01-脚手架
How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
On which platform is it safe to buy shares and open an account? Ask for sharing
In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
tp6自动执行的文件是哪个?tp6核心类库有什么作用呢?
wav文件(波形文件)格式分析与详解
二、训练fashion_mnist数据集
配置、软件配置项、软件配置管理项辨析
Notes on key words in the original English work biography of jobs (V) [chapter three]
Exchange: manage calendar permissions
Jmeter中的断言使用讲解
Summary of hardfault problem in RTOS multithreading
《乔布斯传》英文原著重点词汇笔记(五)【 chapter three 】