Oracle substr function usage

Source: Internet
Author: User
Tags oracle substr

Oracle substr function usage

Obtain the string substr (string, start_position, [length]) with the specified start position and length in the string.

Substr (string, truncation start position, truncation length) // return the truncated word;

When start_position is set to timing, the string is obtained from left to right;

When start_position is negative, the string is obtained from right to left;

When start_position is 0, the string is obtained from the start position of the string;

 

Examples:

1. start_position = 0

Select substr ('hello',) FROM dual; -- El
Select substr ('hello', 0, 6) FROM dual; -- hello
Select substr ('hello', 0, 0) FROM dual; -- null
Select substr ('hello', 0) FROM dual; -- hello

2. start_position> 0

Select substr ('hello', 1, 0) FROM dual; -- null
Select substr ('hello', 1, 2) FROM dual; -- he
Select substr ('hello', 1, 6) FROM dual; -- hello
Select substr ('hello', 1) FROM dual; -- hello

3. start_position <0

Select substr ('hello',-3) FROM dual; -- 'llo'
Select substr ('hello',-1) FROM dual; -- 'O'
Select substr ('hello',-3, 2) FROM dual; --'ll'
Select substr ('hello',-7) FROM dual; -- null

 

Replace () for Oracle Functions ()

Oracle Functions

Differences in case and decode usage and Performance Comparison of Oracle Functions

Simple Oracle functions and stored procedures

The Oracle function obtains the time period in seconds or minutes.

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.