The SUBSTR Function : SUBSTR « Character String Functions « Oracle PL/SQL Tutorial






The SUBSTR function returns part of a string.

The general syntax of the function is as follows:

SUBSTR(original string, begin [,how far])

An original string is to be dissected beginning at the begin character.

If 'how far' amount is not specified, then the rest of the string from the begin point is retrieved.

If begin is negative, then retrieval occurs from the right-hand side of original string.

SQL> SELECT SUBSTR('My address is 123 Fourth St.',1,12)FROM dual
  2  /

SUBSTR('MYAD
------------
My address i

SQL>








11.18.SUBSTR
11.18.1.The SUBSTR Function
11.18.2.substr(,) and substr(,,)
11.18.3.SUBSTR(x, start [, length]) returns a substring of x that begins at the position specified by start.
11.18.4.Substr retrieves a portion of the string
11.18.5.Retrieval begins at position 5 and again goes for 12 characters
11.18.6.A retrieval with no third argument: it starts at begin and retrieves the rest of the string
11.18.7.If begin is negative, then retrieval occurs from the right-hand side of original string
11.18.8.SUBSTR and INSTR used together
11.18.9.Combine SUBSTR and INSTR to deal with a table column
11.18.10.Combine DECODE and SUBSTR together
11.18.11.Example SELECT output using SUBSTR().
11.18.12.substr birthday
11.18.13.Compare substring in where statement
11.18.14.Manipulating Strings: SUBSTR and concatenation
11.18.15.substr(date value,8)+16