Let’s Look at PostgreSQL’s ARRAY_REMOVE() Function

We can use the array_remove() function in PostgreSQL to remove elements from an array.

We pass two arguments when calling the function; the first is the array and the second argument is the element to remove. All occurrences of the specified element are removed.

The function returns an identical array, but without the specified element/s.

Read more

Understanding the BTRIM() Function in PostgreSQL

PostgreSQL has a function called btrim() that we can use to trim both sides of a string. We can trim blank spaces or we can specify certain characters to trim.

It removes the longest string containing only characters from the ones we specify. If we don’t specify any characters, then it removes blank spaces from both sides.

We provide the string as the first argument, and the (optional) characters as the second.

Read more

Using STRING_TO_TABLE() in PostgreSQL

In PostgreSQL, we can use the string_to_table() function to return a set of rows, each containing a part of the string. The string is split based on the specified delimiter.

If we specify a null delimiter, then each character becomes a separate row in the output. If the delimiter string is empty, then the whole string is returned in a single row.

We also have the option of turning a specific substring into null if required.

Read more