One, the string function
LENGTH (CHAR):
SELECT LENGTH ('abc def GH' from dual; -- gets the length of the string that contains the space result:
CONCAT (CHAR1,CHAR2)
SELECTCONCAT ('ABC','def') fromDual--Connect two stringsResults:'abcdef'SELECT 'ABC'||'def' fromDual--Connect two stringsResults:'abcdef'
Initcap (CHAR):
SELECT Initcap ('hello' from dual; -- first letter to uppercase result: Hello
LOWER (CHAR):
SELECT LOWER ('HELLOWorld' from dual; -- convert string to lowercase result: Hello World
UPPER (CHAR):
SELECT UPPER ('helloworld' from dual; -- convert string to uppercase result: HELLO World
LTRIM (Char,set):
SELECT LTRIM (' Hello World' from dual; -- remove whitespace from the left of the string result:'hello world'
RTRIM (Char,set):
SELECT RTRIM (' Hello World' from dual; -- remove whitespace to the right of the string result:' helloworld'
TRANSLATE (char,from,to):
SELECTTranslate ('Abcdefabcdef','ABC','123') fromDual--Replace ABC with 123 if the replacement character is contiguousResults:'123def123def'SELECTTranslate ('Abcdefabcdef','Ace','123') fromDual--if characters are not contiguous, they are replaced by lettersResults:'1b2d3f1b2d3f'
REPLACE (CHAR,SEARCH_STR,REPLACE_STR)
SELECT REPLACE ('abcdefabcdef','abc','123' from dual; -- Replace the string ABC with the 123 result: 123def123def
INSTR (Char,substr[,pos])
SELECTINSTR ('Abcdefabcdef','def') fromDual--Find the Def position in the string, starting with 1Results:4SELECTINSTR ('Abcdefabcdef','def',5) fromDual--finds the DEF position in the string starting at the specified position, starting with 1The result is:Ten
SUBSTR (Char,pos,len)
SELECTSUBSTR ('ABCDEFGH',3) fromDual--intercepts the string from the 3rd bit to the endResults:'CDEFGH'SELECTSUBSTR ('ABCDEFGH',3,2) fromDual--Intercept 2 strings starting from 3rd bitResults:'CD'
Oracle Basic (11) String function