Oracle String Functions

Source: Internet
Author: User

1. Replace,translate

--translate character-level substitution--Replace string-level substitutionSelect Replace('abaabbb','AB','C') fromDual--CACBBSelectTranslate'aaabbb','AB','CE') fromDual--ccceee

2. Concat string connection, equivalent to | |

Select concat ('test'_concat ' from dual;  --test_concatSelect'test'| | ' _concat '  from -- Test_concat

3. Upper,lower,initcap specifying a language set: Nls_upper,nls_lower,nls_initcap

Select Upper('aaaaaa') fromDual--aaaaaaSelect Lower('aaaaaa') fromDual--aaaaaaSelectInitcap ('AAAAA') fromDual--AaaaaSelectInitcap ('AAA AAA') fromDual--AAA AAA

4.lpad,rpad string padding, if no padding character is specified, the default is a space

Select lpad ('aa',ten,'0' from -- left padding  00000000aaSelect rpad ('aa',ten,'  0'from-- right fill  aa00000000

5. Ltrim,rtrim,trim (Leading,trailing,both) string trimming, trim only supports single character pruning? Default cut-off spaces

Select LTrim('111111111000123000',' on') fromDual--cut off all 0 and 1 23000 from the left .Select RTrim('00012300011111','012') fromDual----Cut all 0 and 1 000123 from the rightSelectTrim (Leading'0'  from '000123000') fromDual--Cut all 0 from the beginning.123000SelectTrim (Trailing'0'  from '000123000') fromDual--cut off all 0 000123 from the tail.SelectTrim (both'0'  from '000123000') fromDual--Both sides cut all 0 123.

6. substr

--substr (char,start,length) intercepts a char string with length starting from StartSelectSubstr'ABC',0,1) fromDual--returns aSelectSubstr'ABC',1,1) fromDual--Start is 0 and start is 1 effectSelectSubstr'Abcdefgs',-5,3) fromDual--If start is a negative number, the return def is intercepted starting from the countdown start characterSelectSubstr'Abcdefgs',-5) fromDual--if length is omitted, the string to start until the end is truncated to return DEFGS

7. Regexp_substr,regexp_replace

Oracle String Functions

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.