Single-line function

Source: Internet
Author: User

Simple function:

For example: Now you want letters to be capitalized. Such a function can be done using a single-line function.

Core of several.

String functions, numeric functions, date functions, conversion functions, general functions.

Requires the name of a single-line function, returns a value type, and accepts the type of the parameter.

String functions

Turn capital

String UPPER (String | Data column)

Turn lowercase

String LOWER (String | Data column)

Example:

SELECT UPPER (' Hello '), LOWER (' Hello ') from dual; Show ' Hello ' in virtual table

SELECT LOWER (ename) from EMP; Show employee names in lowercase

Use these two features to turn user information into a uniform uppercase or lowercase.

Example:

For example, enter the message ' Smith ' to output ' Smith '.

Oracle has an alternative operation that

For example:

SELECT * from &tablename;

SELECT * from EMP WHERE ename= UPPER (' &name ');

First letter uppercase, remaining letter lowercase

/td>

String Initcap (String | column)

Calculation Length of string

Length (string | column)

Replaces the contents of the specified string,

String replace (String | column, content to replace, replace)

Intercept operation.

SUBSTR (string | column, intercept start index)

 

substr  (string | column, intercept start index, knot Bundle index)

Remove left and right spaces

TRIM (word Character string | column)

Convert first Letter Capital Select Initcap (ename) from EMP; Calculate length Select Length ('Hello') from EMP; SELECT ename, LENGTH (ename) from EMP; SELECT ename from emp WHERE LENGTH (ename)=5; Replace operation Select Replace ('Hello World','L','_') from EMP; SELECT ename,replace (ename,'A','_') from EMP; intercept operation Select SUBSTR ('Hello World',7) from DUAL; SELECT SUBSTR ('Hello World',7,9from DUAL; The Intercept starts at 1, not 0SELECT ename,substr (ename,1,3) from EMP; First three-bit select Ename,substr (ename,length (ename)-2, LENGTH (ename)) From EMP; The three-bit removal of the left and right spaces after the name is removed select TRIM ('Helllo World') from DUAL;

Numeric functions:

Single-line function

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.