Oracle string manipulation: stitching, replacing, intercepting, finding

Source: Internet
Author: User

First, stitching strings

1. Use "| |" To stitch Strings:

Select ' Stitching ' || ' string '  as Str  from student;

2, using the concat (PARAM1,PARAM2) function to achieve:

Select concat (' concatenation ',' string 'asStr  from student;

Note: Oracle's Concat () method supports only two parameters, and if you stitch multiple parameters, you can nest concat ():

Select concat (concat (' concatenation ',' string '),'  AB'asStr from student;

Ii. Interception of strings

SUBSTR (String,start_position,[length]), get substring

String: Source string

Start_position: Start position

Length: string lengths [optional]

1substr ("ABCDEFG",0);//return: ABCDEFG, intercept all characters2substr ("ABCDEFG",2);//return: CDEFG, intercept all characters after starting with C3substr ("ABCDEFG",0,3);//return: ABC, intercept starting from a 3 characters4substr ("ABCDEFG",0, -);//return: abcdefg,100 The maximum number of preprocessed strings is returned, although it exceeds the length of the preprocessed string, but does not affect the return result. 5substr ("ABCDEFG",-3);//Back to: EFG, note parameters-3, a negative value indicates that the string is positioned unchanged from the beginning of the tail.

Third, find the string

INSTR (string,substring,position,ocurrence) Find string position

String: Source string
SubString: substring to find
Position: Where to find start
Ocurrence: A substring of the first occurrence of a source string

Select INSTR ('CORPORATEfloor','OR'32as   from

Iv. replacing strings

Replace (strsource, STR1, STR2) replaces str1 in strsource with str2

Strsource: Source string

STR1: the string to replace

STR2: Replaced string

Select ' Replace string '  as Replace (' replace string ' ' replace  ' ' modify  '  as  from dual

Note: This article refers to the original: https://www.cnblogs.com/smallrock/p/3507022.html

Oracle string manipulation: stitching, replacing, intercepting, finding

Related Article

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.