SUBSTRING function

SUBSTRING returns a specified substring of a string.

Signatures

substring(str, start_pos)
substring(str, start_pos, len)
substring(str FROM start_pos)
substring(str FOR len)
substring(str FROM start_pos FOR len)
Parameter Type Description
str string The base string.
start_pos int The starting position for the substring; counting starts at 1.
len int The length of the substring you want to return.

Return value

substring returns a string.

Examples

SELECT substring('abcdefg', 3) AS substr;
 substr
--------
 cdefg

SELECT substring('abcdefg', 3, 3) AS substr;
 substr
--------
 cde
Back to top ↑