Home  >  Article  >  Database  >  How to intercept the last few digits of a string in oracle

How to intercept the last few digits of a string in oracle

WBOY
WBOYOriginal
2022-01-06 16:13:2536451browse

In Oracle, you can use the substr function to intercept the last few digits of a string. This function is also called the character interception function. It is used to intercept the specified characters in the string. The syntax is "substr(need to intercept String, - the number of digits that need to be intercepted, the number of digits that need to be intercepted)".

How to intercept the last few digits of a string in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How does oracle intercept the last few digits of a string

Introduction to the use of substr function format (commonly known as: character interception function):

Format 1: substr(string string, int a, int b);

  • 1. string The string to be intercepted

  • 2. a intercepts the starting position of the string (note: when a is equal to 0 or 1, interception starts from the first position)

  • 3. b The string to be intercepted The length of

Format 2: substr(string string, int a);

  • 1. string The string to be intercepted

  • 2. a can be understood as intercepting all subsequent strings starting from the a-th character.

The example is as follows:

select substr('HelloWorld',-4,4) value from dual;

Return result: orld

Take 4 characters starting from the 4th digit from the bottom.

Also:

How to intercept the last few digits of a string in oracle

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of How to intercept the last few digits of a string in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn