Basic Learning for Oracle (III)-Single-line function

Source: Internet
Author: User

One, character functions

1. Casing control function

--lower: Make the letter lowercase----upper: Make the letter uppercase----INITCAP: Make the first letter of the character uppercase--select   lower (' ABC '),  Upper (' sql '),  Initcap (' HeLlo SQL ') from dual;

Select employee_id, Department_id,last_name, salary from  employees where lower (last_name) = ' King ';

2. Character control functions

Concat (STR1,STR2)

Connect two strings.

SUBSTR (Str,index,n)

Intercepts the string, starting at index (the SQL string subscript the first 1) and intercepting n lengths.

Length (str)

Gets the length of str.

InStr (STR1,STR2)

STR2 the first occurrence of the index in STR1, if not present returns 0.

Lpad (STR1,LEN,STR2)

Set the str1 length to Len, if the length is not enough on the left with STR2.

Rpad (STR1,LEN,STR2)

Set the str1 length to Len, if the length is not enough on the right with str2.

Trim (Str1,from str2)

Remove the st1 from the str2, just the first and the tail.

Replace (STR,STR1,STR2)

Replace the str1 in Str with the STR2, all replaced.

Select  concat (' Hello ', ' sql '), substr (' Hellosql ', 2,4), InStr (' HelloWorld ', ' o '), Length (' Hello SQL ') from dual;

Select Employee_id,last_name, Salary,lpad (salary,10, ' * ') from  employees where department_id=80;

--trim: Just remove the first composite----Replace: Replace all--select  trim (' A ' from ' AABBAACCAA '), replace (' AABBAACCAA ', ' a ', ' M ') from dual;

Second, the number function

Round: Rounding function.

Trunc: Truncation function.

MoD: Find the remainder function.

--round: Rounded--select    round (435.45,1),   round (435.45),   round (435.45,-1) from dual;

--trunc: Truncate--select    trunc (435.45,1),   trunc (435.45),   trunc (435.45,-1) from dual;

Basic Learning for Oracle (III)-Single-line function

Related Article

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.