PostgreSQL provides us with various string functions, including some that allow us to trim a given string on both sides or a given side.
Below are four functions that we can use to trim strings in PostgreSQL.
PostgreSQL provides us with various string functions, including some that allow us to trim a given string on both sides or a given side.
Below are four functions that we can use to trim strings in PostgreSQL.
Anyone who looks at PostgreSQL’s list of mathematical functions will notice that there are some functions that have “scale” in their name. In particular, scale(), min_scale(), and trim_scale().
While these functions all have a similar name, they each have a different purpose. That said, they’re all related to the scale of the given number. The scale is the number of digits to the right of the decimal point in a number. For example, the number 1.95 has a scale of 2, and 1.958 has a scale of 3.
Below is an alphabetical list of functions that we can use when working with arrays in PostgreSQL.
In PostgreSQL, factorial() is a mathematical function that returns the factorial of a given integer. We pass the integer (it accepts bigint), and it returns the factorial as a numeric value.
In mathematics, the factorial is the product of all positive integers less than or equal to a given positive integer. It’s denoted by that integer and an exclamation point.
In PostgreSQL, the md5() function computes the MD5 hash of the specific text, and outputs the result in hexadecimal.
We pass the text as an argument when calling the function.
PostgreSQL sometimes provides us with multiple functions that basically do the same thing. Such is the case with the following two functions that return the position of a given substring within a string.
In PostgreSQL, we can use the to_hex() function to convert a number to its equivalent hexadecimal representation.
The function accepts the number as an integer or bigint, and it returns the result as a text representation of its hexadecimal equivalent.
In PostgreSQL, we can use the ascii() function to get the numeric code of the first character of the argument.
When using UTF8, the function returns the Unicode code point of the character. Other multibyte encodings require an ASCII character.
The PostgreSQL split_part() function splits a string based on a specified delimiter and then returns the specified part from the split string.
The function accepts three arguments; the string, the delimiter, and the part that we want to return.
In PostgreSQL, we can use the pg_client_encoding() function to get the current client encoding name.