In PostgreSQL, gcd()
is a mathematical function that returns the greatest common divisor. We pass two numbers and the function returns the largest positive number that divides both inputs with no remainder.
Tag: what is
An Overview of PostgreSQL’s LCM() Function
In PostgreSQL, lcm()
is a mathematical function that returns the least common multiple. We pass two numbers and the function returns the smallest strictly positive number that is an integral multiple of both inputs.
Understanding Composite Types in PostgreSQL
In PostgreSQL, a composite type is a kind of data type that consists of multiple data types. It consists of a list of field names and their respective data types.
We can use composite types to fit multiple fields into one column.
We can create our own custom composite types, and they can be used in many of the same scenarios that simple data types can be used.
Continue readingUnderstanding PostgreSQL’s TRANSLATE() Function
PostgreSQL has a translate()
function which replaces certain characters in a string with certain other characters.
We specify the characters in the string that we want to replace, as well as the characters that we want to replace them with. The function then performs the translation and returns the string with the replaced characters.
Continue readingA Quick Look at TO_ASCII() in PostgreSQL
In PostgreSQL, we can use the to_ascii()
function to convert a string to ASCII from another encoding. This usually involves dropping any accents (diacritic signs) from the original string.
We pass the string as an argument to the function. We also have the option of specifying the encoding (either its name or its number).
Continue readingOverview of the REPEAT() Function in PostgreSQL
We can use PostgreSQL’s repeat()
function to repeat a string multiple times. We pass the string to the function, along with an integer that specifies how many times we want it repeated, and it returns the string repeated that many times.
Using REGEXP_SPLIT_TO_ARRAY() in PostgreSQL
In PostgreSQL, the regexp_split_to_array()
function splits a string using a POSIX regular expression as the delimiter, and returns the result in a text array.
So we use a POSIX regular expression to specify the delimiter/s, and split the string based on that.
We pass the string as the first argument and the pattern as the second. We can also specify a flag to determine how the function behaves.
Continue readingHow REGEXP_SPLIT_TO_TABLE() Works in PostgreSQL
In PostgreSQL, the regexp_split_to_table()
function splits a string using a POSIX regular expression as the delimiter, and returns the result in a table.
So we use a POSIX regular expression to specify the delimiter/s, and split the string based on that.
We pass the string as the first argument and the pattern as the second. We can also specify a flag to change the behaviour of the function.
Continue readingA Quick Look at PostgreSQL’s STARTS_WITH() Function
When using PostgreSQL, we can use the starts_with()
function to check whether or not a string starts with a given substring.
We pass the string as the first argument, and the substring as the second.
It returns true if the string does start with the substring, otherwise it returns false.
Continue readingHow PostgreSQL’s SOME() Construct Works
PostgreSQL has the SOME()
construct that we can use to perform searches against arrays. It returns a Boolean result, and so we can incorporate this into our searches to return just those rows that yield true or false.
SOME()
is a synonym for ANY()
, and so we can use either one to get the same result.