PostgreSQL SPLIT PART Function

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PostgreSQL SPLIT_PART() function

SPLIT_PART() function

The PostgreSQL split_part function is used to split a given string based on a delimiter and pick out the desired field from the string, start from the left of the string.

Syntax :

split_part(<string>,<delimiter>, <field_number>)

PostgreSQL Version : 9.3

Pictorial Presentation of PostgreSQL SPLIT_PART() function

Example : PostgreSQL SPLIT_PART() function :

In the example below, the delimiter of the defined string is '-#-' and specified field number is 2. So the split_part function splits the second field from the specified string.

SELECT split_part('ordno-#-orddt-#-ordamt', '-#-', 2);

Output :

(1 row)