SUBSTR Intercept string

Source: Internet
Author: User


The SUBSTR functions return a portion of chars, beginning at character position, substring_length characters long. SUBSTR calculates lengths using characters as defined by the input character set. SUBSTRB uses bytes instead of characters. SUBSTRC uses Unicode complete characters. SUBSTR2 uses UCS2 code points. SUBSTR4 uses UCS4 code points.

If position is 0, then it is treated as 1.

If position is positive, then Oracle Database counts from the beginning of-

If position is negative, then Oracle counts backward to the end of Char.

If Substring_length is omitted, then Oracle returns all characters to the "end of". If Substring_length is less than 1, then Oracle returns NULL.

Char can is any of the datatypes char, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. Both position and Substring_length must being datatype number, or any datatype so can is implicitly converted to number, and must resolve to an integer. The return value was the same datatype as char. Floating-point numbers passed as arguments to SUBSTR are automatically erted to integers.

Also:oracle Database Globalization Support Guide For more information about SUBSTR functions and length semantics in Different locales


The following example returns several specified substrings of "ABCDEFG":

Select SUBSTR (' ABCDEFG ', 3,4) "Substring" from

SELECT SUBSTR (' ABCDEFG ', -5,4) "Substring" from


Assume a double-byte database character set:

select substrb (' ABCDEFG ', 5,4.2) "Substring with bytes" from DUAL; Substring with bytes--------------------CD 

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: 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.