Oracle SUBSTRING Function Explained

The SUBSTRING function in Oracle is used to extract a substring from a string. It works by cutting out a portion of a string based on a specified starting position and length.

The syntax for the SUBSTRING function is as follows:

Extract a portion of text from a given string starting from a specific position and with a specific length.

Among them:

  1. The string is the specified string to be extracted.
  2. The start_position indicates the starting point of the substring to be extracted, starting from 1.
  3. Length is the length of the substring to be extracted.

For instance, if there is a string ‘Hello World’, we can use the SUBSTRING function to extract a substring from it. For example, SUBSTRING(‘Hello World’, 7, 5) will return ‘World’, as the starting position is 7 and the length is 5.

It is important to note that there is a similar function in Oracle called SUBSTR, which is similar to SUBSTRING but its starting position is from 0. Therefore, SUBSTR(‘Hello World’, 6, 5) will return ‘World’.

bannerAds