Oracle's SUBSTR function

Source: Internet
Author: User

First, substr function

SUBSTR (target string, start position, length)

Note: Here the third parameter: length, equivalent to the scalar in physics, there is no directionality, so you cannot use negative values. Although no error, but choose No value out ( please correct )

The start position can have a negative value, indicating the reciprocal. For example: substr (ename,-2,2): Indicates that a string of length 2 is truncated from the first countdown

Example 1:

Sql> Select Ename,substr (ename,1,3) from EMP;

Ename SUBSTR
----------    ------
SMITH SMI
ALLEN All
WARD WAR
JONES JON
MARTIN MAR
BLAKE BLA
CLARK CLA
SCOTT SCO
KING KIN
TURNER TUR
ADAMS ADA
JAMES JAM
FORD for
MILLER MIL

14 rows have been selected.

Example 2:

Sql> Select Ename,substr (ename,-2,2) from EMP;

Ename SUBS
---------- ----
SMITH TH
ALLEN EN
WARD RD
JONES ES
MARTIN in
BLAKE KE
CLARK RK
SCOTT TT
KING NG
TURNER ER
ADAMS MS
JAMES ES
FORD RD
MILLER ER

14 rows have been selected.

Example 3:

Sql> Select Ename,substr (ename,2,-2) from EMP;

Ename S
---------- -
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
Adams
JAMES
FORD
MILLER

14 rows have been selected.

Oracle's SUBSTR 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.