In PostgreSQL, we can use the array_append()
function to append an element to the end of an array.
The first argument is the array, and the second argument is the element to append.
Continue readingIn PostgreSQL, we can use the array_append()
function to append an element to the end of an array.
The first argument is the array, and the second argument is the element to append.
Continue readingPostgreSQL has an array_positions()
function that returns the position of the all occurrences of a given value in an array.
There’s also a array_position()
function (singular) that returns the position of just the first occurrence. So to get just the first occurrence, use that function instead.
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.
In PostgreSQL we can use the cardinality()
function to return the total number of elements in an array. This includes elements across all dimensions of the array.
We pass the array as an argument to the function, and it returns an integer of the total number of elements in that array.
Continue readingPostgreSQL has an array_position()
function that returns the position of the first occurrence of a given value in an array.
We have the option to specify a starting position, so that the function returns the position of the first occurrence after that.
To get all occurrences, use array_positions()
instead.
In PostgreSQL, the array_upper()
function returns the upper bound of the specified array dimension. We pass the array as well as the dimension, and it returns the upper bound accordingly.
In PostgreSQL, the array_lower()
function returns the lower bound of the specified array dimension. We pass the array and the relevant dimension, and it returns the lower bound for that dimension.
In PostgreSQL the array_ndims()
function returns the number of dimensions of an array. We pass the array to the function, and it returns an integer of the number of dimensions in the array.
This function is not to be confused with the array_dims()
function, which returns a more detailed text representation of the dimensions in the array.
In PostgreSQL we can use the array_dims()
function to return information about the dimensions in an array. The function accepts the array in question, and it returns a text representation of the array’s dimensions.
This function is not to be confused with the array_ndims()
function, which simply returns the number of dimensions in an array.
In PostgreSQL we can use the random_normal()
function to generate a normally-distributed random number.
A normally-distributed random number is a random variable with a Gaussian distribution. This is said to be normally distributed, and is referred to as a normal deviate.
Continue reading