Introduction to the two functions in Oracle Functions

Source: Internet
Author: User

In the actual application of Oracle functions, we often use the following two functions, this includes the character manipulation function CONCAT, and the actual application and features of the character manipulation function CONCAT in this article.

Character manipulation functions ------> CONCAT

 
 
  1. select empno,concat(ename,job) from scott.emp;<=>select ename||job from scott.emp;  
  2. EMPNO CONCAT(ENAME,JOB)  
  3. 7369 SMITHCLERK  
  4. 7499 ALLENSALESMAN  
  5. /LENGTH  
  6. select empno,ename,length(ename) from scott.emp;  
  7. EMPNO ENAME LENGTH(ENAME)  
  8. 7369 SMITH 5  

2. select length ('classices') from dual;

LENGTH ('class ')

3

 
 
  1. /SUBSTR  
  2. select empno,ename,substr(ename,1,4) from scott.emp;  
  3. EMPNO ENAME SUBSTR(E  
  4. 7369 SMITH SMIT  
  5. 7499 ALLEN ALLE

/INSTR return position value

 
 
  1. SQL> select ename,instr(ename,'S') from scott.emp;  
  2. ENAME INSTR(ENAME,'S')  
  3. SMITH 1  
  4. ALLEN 0  
  5. WARD 0  
  6. JONES 5  

/LPAD displays the string in some Mode

 
 
  1. SQL> select ename,lpad(ename,10,'*') from scott.emp;  
  2. ENAME LPAD(ENAME,10,'*')  
  3. SMITH *****SMITH  
  4. ALLEN *****ALLEN  
  5. WARD ******WARD  
  6. JONES *****JONES  

In Oracle functions, numeric functions: ROUND is the most widely used function.

 
 
  1. SELECT ROUND(45.923,2),ROUND(45.923,0),ROUND(45.923,-1)  
  2. FROM DUAL;  

Result:

In order: 45.92 46 50

 
 
  1. /TRUNC  
  2. SELECT TRUNC(45.923,2),TRUNC(45.923,0),TRUNC(45.923,-1)  
  3. FROM DUAL;  
  4.  

Result:

In order: 45.92 45 40

/MOD

The above content is an introduction to several common Oracle functions. I hope you will find some gains.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.