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 PG 18 manual ↗

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

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 4
  1. PG 14 → 15changed
  2. PG 13 → 14changed
  3. PG 12 → 13changed
  4. PG 9.0 → 9.1changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source