↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / String Functions And Operators

Splits string at occurrences of delimiter and returns the n'th field (counting from one), or when n is negative, returns the |n|'th-from-last field.

Reading PG 18current·documented in 25 of 27 versions, 7.3 to 20

Signatures & examples

split_part ( string text, delimiter text, n integer ) → text
Splits string at occurrences of delimiter and returns the n'th field (counting from one), or when n is negative, returns the |n|'th-from-last field.
split_part('abc~@~def~@~ghi', '~@~', 2) → def
split_part('abc,def,ghi,jkl', ',', -2) → ghi
Version history 5
  1. 13 → 14 changed
  2. 12 → 13 changed
  3. 8.0 → 8.1 changed
  4. 7.3 → 7.4 changed
  5. 7.2 → 7.3 added

Definition snapshot: b7bd9cda · English manual source