postgresqlHow do I split a string in PostgreSQL?
PostgreSQL provides a built-in function to split a string into an array of substrings based on a specified delimiter. This function is called string_to_array()
.
The syntax for the string_to_array()
function is as follows:
string_to_array(string text, delimiter text)
Example
SELECT string_to_array('1,2,3,4,5', ',');
-- Output:
{"1","2","3","4","5"}
The string_to_array()
function takes two arguments:
string
- The string to be split.delimiter
- The character or characters used to separate the string.
The string_to_array()
function returns an array of substrings.
Helpful links
More of Postgresql
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL XOR to compare two values?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I monitor PostgreSQL performance using Zabbix?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I use PostgreSQL with YAML?
- How do I install and configure PostgreSQL on a Windows machine?
- How can I use PostgreSQL XML functions to manipulate XML data?
- How can I use PostgreSQL with Zabbix?
See more codes...