Recall & Review
beginner
What PostgreSQL function converts a string into an array?
The
string_to_array(text, delimiter) function splits a string into an array using the specified delimiter.Click to reveal answer
beginner
How do you convert an array back into a string in PostgreSQL?
Use the
array_to_string(array, delimiter) function to join array elements into a single string separated by the delimiter.Click to reveal answer
beginner
Example: What is the result of
string_to_array('apple,banana,cherry', ',')?It returns the array
{apple,banana,cherry} splitting the string at each comma.Click to reveal answer
beginner
Example: What does
array_to_string(ARRAY['red', 'green', 'blue'], ';') return?It returns the string
'red;green;blue' joining array elements with semicolons.Click to reveal answer
intermediate
Why are string to array and array to string conversions useful in databases?
They help handle lists stored as text, making it easy to split or join values for searching, filtering, or displaying data.
Click to reveal answer
Which function splits a string into an array in PostgreSQL?
✗ Incorrect
The
string_to_array function splits a string into an array using a delimiter.What does
array_to_string(ARRAY['a','b','c'], ':') return?✗ Incorrect
It joins array elements with ':' resulting in 'a:b:c'.
If you want to split 'dog|cat|bird' into an array, which delimiter should you use?
✗ Incorrect
The delimiter '|' matches the separator in the string.
Which function would you use to join array elements into a single string?
✗ Incorrect
The
array_to_string function joins array elements into a string.What is the output of
string_to_array('one;two;three', ';')?✗ Incorrect
The string is split at each ';' into an array of three elements.
Explain how to convert a comma-separated string into an array in PostgreSQL and why this might be useful.
Think about how you can turn a list in text form into separate pieces.
You got /4 concepts.
Describe how to join an array of strings into a single string with a custom separator in PostgreSQL.
Imagine putting pieces of a puzzle back together with glue.
You got /4 concepts.