Friday 1 April 2016

SQL Substr

This will be used to extract substrings.

     Syntax: substr (string, start_chr_count [, no_of_chars])

Ex:
SQL> select substr('computer',2), substr('computer',2,5), substr('computer',3,7) from dual;

SUBSTR(  SUBST  SUBSTR
----------  -------   --------
omputer  omput   mputer

Ø If no_of_chars parameter is negative then it will display nothing.
Ø If both parameters except string are null or zeros then it will display nothing.
Ø If no_of_chars parameter is greater than the length of the string then it ignores and calculates based on the orginal string length.
Ø If start_chr_count is negative then it will extract the substring from right end.

No comments:

Post a Comment