↑↓ select ↵ open ⌫ change scope Open full search

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

Functions / String Functions And Operators

string_to_array

Read the PG 18 manual

Splits the string at occurrences of delimiter and forms the resulting fields into a text array.

Reading PG 18current·documented in 24 of 27 versions, 7.4 to 20

Signatures & examples

string_to_array ( string text, delimiter text [, null_string text ] ) → text[]
Splits the string at occurrences of delimiter and forms the resulting fields into a text array. If delimiter is NULL, each character in the string will become a separate element in the array. If delimiter is an empty string, then the string is treated as a single field. If null_string is supplied and is not NULL, fields matching that string are replaced by NULL. See also array_to_string.
string_to_array('xx~~yy~~zz', '~~', 'yy') → {xx,NULL,zz}
Version history 7
  1. 14 → 15 changed
  2. 13 → 14 changed
  3. 12 → 13 changed
  4. 9.0 → 9.1 changed
  5. 8.3 → 8.4 changed
  6. 7.4 → 8.0 changed
  7. 7.3 → 7.4 added

Definition snapshot: b7bd9cda · English manual source