Press "Enter" to skip to content

Using SUBSTRING() in PostgreSQL

Rajendra Gupta builds a substring:

The PostgreSQL substring function returns a subset of the input string based on the supplied string starting position and length. You can use the SUBSTRING function for extracting data as per fixed string length and regular expressions.

Syntax:

SUBSTRING (String, Start_Position, length)

Read on for some common uses, as well as cases that are a bit more esoteric.