当前位置:网站首页>Oracle built-in functions
Oracle built-in functions
2022-07-28 21:57:00 【Xiao Lei y】
Oracle Built in functions
1. Classification of built-in functions
- Built in functions :Oracle Self contained function , Just call it , No need to define
- Oracle The built-in functions are divided into the following categories :
- Conversion function ; Convert data types
- Date function ;
- Character functions ;
- Number function ;
- Set function ;
2. Conversion function
2.1 to_char();
- effect : Convert a non character type to a character type ;
-- Call the current system date
select sysdate from dual;
-- Date type to character type
-- Convert the current system time to string type , The time format is :xxxx-xx-xx xx:xx:xx
select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;
-- Convert the current system time to string type , Only the date of the year is displayed , The time format is :xxxx-xx-xx
select to_char(sysdate,'yyyy-mm-dd')from dual;
-- Convert the current system time to string type , And the display is 24 hourly , The time format is :xxxx year xx month xx Japan xx:xx:xx
select to_char(sysdate,'yyyy" year "-mm" month "-dd" Japan " hh24:mi:ss') from dual
2.2 to_date();
- effect : Convert the time with large character type to date type ;
-- Put the character type time '2021-08-18' Convert to date type , The format is :xxxx/xx/xx;
select to_date('2021-08-18','yyyy/mm/dd') from dual
-- Put the character type time '2021-08-18 11:33:44' Convert to date type , The format is :xxxx/xx/xx xx:xx:xx;
select to_date('2021-08-18 11:33:44','yyyy/mm/dd hh:mi:ss') from dual
2.3 to_number();
- effect : Convert numbers of character type to numeric type ;
select 1+to_number('1') from dual;
3. Date function
3.1 add_months()
- effect : Add a specified number of months to the specified date , Find the current date ;
- Be careful : This can only work on date types ;
-- Find the current system time 100 The date after months ;
select add_months(sysdate,100) from dual;
-- seek 2020 year 8 month 8 Japan ,100 The date after months ;
select add_months(to_date('2020-8-8','yyyy-mm-dd'),-2) from dual;
-- seek 2020 year 8 month 8 Japan ,100 The date three months ago ;
select add_months(to_date('2020-08-08','yyyy-mm-dd'),-100)from dual;
3.2 extract()
- effect : Take the month, year and day in the date separately ;
- Be careful : It can only work with date type ;
-- Take the year of the current system time
select extract(year from sysdate)from dual;
-- Take the month of the current system
select extract(month from sysdate)from dual;
-- Take the current system time and date
select extract(day from sysdate)from dual;
-- seek emp table 2 Number of employees in the month
select count(*)from emp where extract(month from hiredate)=2;
-- seek emp The number of employees in each month in the table
select extract(month from hiredate),count(*)from emp group by extract(month from hiredate);
3.3 months_between()
- effect : Find the month of the difference between two times ;
- Be careful : Can only act on date types ;
-- seek 2020-2-2 The month that is different from the current system time ;
select months_between(sysdate,to_date('2017-02-02', 'yyyy/mm/dd')) from dual;
3.4 Last_day()
- effect : Ask for the last day of this month ;
-- Find the last day of the current month ;
select last_day(sysdate) from dual;
-- seek 2021 The last day of the year ;
select last_day(to_date('2021-12', 'yyyy-mm'))from dual;
3.5 Next_day()
- effect : Find the date of the next specified week ;
- Be careful : Can only act on date types ;
-- Find the date of next Saturday ;
select next_day(sysdate,' Saturday ')from dual;
4. Character functions
select upper('abcdAsdfa') from dual;
-- Capitalize all ;
select lower('abcdAsdfa') from dual;
-- All to lowercase ;
select trim('abcd','a') from dual;
-- Remove the left character ( The first character is a Then remove , On the contrary, do not remove );
select trim ('acccsdfdsccccbcd','c') from dual:
-- Remove the character on the right ( The first character is c Then remove , On the contrary, do not remove );
select initcap('adad') from dual;
-- Convert initials to uppercase ;
select substr('abcdefghi',3,4) from dual;
-- Cut from the third place , section 4 individual ;
select instr('abcdefg', 'c') from dual;
-- Judge c The location of , Subscript from 1 Start ;
select concat ('aa', 'bb') from dual;
-- This means splicing , Less use , Because we can use || Instead of ;
select ascii('a') from dual;
-- seek a Of ic code ;
select char(77) from dual;
-- take ic The code is converted into the corresponding value character ;
select length ('abcd Zhang ') from dual;
-- Find the number of characters , Not the number of bytes ;
select (pad ('abde' ,9,'x') from dual;
-- padding-left , Start from the left x’ fill , Until the length of bytes becomes 9 until ;
select rpad ('abde' ,9,'x') from dual;
-- Right fill , Start from the edge x fill , Until the length of bytes becomes 9 until ;
select decode('c', 'a',1,'b',2,'c',3) from dual;
-- The result is 3, It means to judge several results , If the preceding symbol is a It outputs 1, If it is b It outputs 2, If it is c It outputs 3;
5. Mathematical functions
select ceil (57.12) from dual;
-- Rounding up ;
select floor (57.98) from dual;
-- Don't round ;
select round (54.99) from dual;
-- The result is 55, rounding ;
select round (54.59,1) from dual;
-- Round to the nearest decimal point 1 digit ;
select power (3,2) from dual;
--3 Of 2 Power
select mod (6,7) from dual;
-- Remainder / model ;
select sqrt (4) from dual;
-- Square root ;
select sign (0) from dual;
-- If it is a positive number, the result is 1, If it is negative, the result is -1, If it is 0, The results for 0;
6. Comprehensive case
If the salary is less than 3500 It outputs “ Work hard ”, If it is equal to 3500 It outputs “ It is just fine ”, If it is greater than 3500 It outputs “ To pay taxes ”
select ename, decode(sign(sal-3500),1,' To pay taxes ',0,' It is just fine ',-1,' Work hard ')from emp;
7. Aggregate functions
7. Aggregate functions .
- sum, max, min, avg, count.
边栏推荐
- 搞事摸鱼一天有一天
- 标准C语言学习总结10
- 基于BRNN的政务APP评论端到端方面级情感分析方法
- Research on intangible cultural heritage image classification based on multimodal fusion
- 纳米金偶联抗体/蛋白试剂盒(20nm,1mg/100μg/500 μg偶联量)的制备
- [brother hero July training] day 28: dynamic planning
- Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
- 酷派主动终止针对小米公司的专利侵权诉讼
- 融合LSTM与逻辑回归的中文专利关键词抽取
- Data interpolation -- normalize data of different magnitude
猜你喜欢

HCIA综合实验(以华为eNSP为例)

LeetCode·581.最短无序连续子数组·双指针

纳米金偶联抗体/蛋白试剂盒(20nm,1mg/100μg/500 μg偶联量)的制备

顺序表的实现

Nano gold coupled antibody / protein Kit (20nm, 1mg/100 μ g/500 μ G coupling amount) preparation
![[Bluetooth Bluetooth development] VIII. Transmission layer of ble protocol](/img/43/7c3891befcb7cbb7dc67dfdeb763e2.png)
[Bluetooth Bluetooth development] VIII. Transmission layer of ble protocol

Leetcode linked list question - interview question 02.07. linked list intersection (learn linked list by one question and one article)

kingbase中指定用户默认查找schema,或曰用户无法使用public schema下函数问题

OA项目之会议通知(查询&是否参会&反馈详情)

Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
随机推荐
Modify the port number of MySQL (is there a problem modifying the port number of MySQL)
基于BRNN的政务APP评论端到端方面级情感分析方法
Is it necessary to calibrate the fluke dtx-1800 test accuracy?
[英雄星球七月集训LeetCode解题日报] 第28日 动态规划
LeetCode链表问题——142.环形链表II(一题一文学会链表)
For the next generation chromebook, MediaTek launched new chipsets mt8192 and mt8195
Leetcode interview question 02.07. Linked list intersection [knowledge points: Double pointers, stack]
Pytorch learning record (4): over fitting, convolution neural network CNN
Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
Standard C language learning summary 10
传微软已获得向华为供货许可!华为将迎来全面解禁?
Record some small requirements in the form of cases
Huawei releases the first electric drive system driveone: charging for 10 minutes, endurance of 200km
PyQt5快速开发与实战 5.4 网页交互
Cy3/cy5/cy5.5/cy7 fluorescent labeling antibody / protein Kit (10~100mg labeling amount)
The general strike of three factories in St France may make the shortage of chips more serious!
How is nanoid faster and more secure than UUID implemented? (glory Collection Edition)
The University was abandoned for three years, the senior taught himself for seven months, and found a 12K job
How to skillfully use assertion + exception handling classes to make the code more concise! (glory Collection Edition)
字节一面:TCP 和 UDP 可以使用同一个端口吗?