Oracle Foundation (11) String functions

Source: Internet
Author: User

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

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.