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