In PostgreSQL we have the ability to create variable-length multidimensional arrays and define columns as array types.
Here’s a quick overview of PostgreSQL arrays.
Continue readingIn PostgreSQL we have the ability to create variable-length multidimensional arrays and define columns as array types.
Here’s a quick overview of PostgreSQL arrays.
Continue readingWhen we create a scheduled event in MySQL, it’s enabled by default. But we can change this.
We can create an event in disabled status, then enable it later. Or we can do the opposite – create it as an enabled event and then disable it later.
Continue readingIf you’re getting a PostgreSQL error that reads “function generate_subscripts(integer, integer) does not exist“, it’s probably because your first argument is not an array. This specific error message implies that the first argument is an integer, but we’d get a similar error when passing a numeric argument.
The first argument for this function must be an array.
To fix this error, be sure that your first argument to generate_subscripts()
is an array.
If you’re getting an error that reads “invalid input syntax for type integer…” when using the array_sample()
function in PostgreSQL, it’s probably because your second argument is not an integer.
The second argument for this function must be an integer.
To fix this error, be sure that your second argument to array_sample()
is an integer.
PostgreSQL has an aggregate function called array_agg()
that allows us to generate an array from the result set of a query.
The function accepts an argument which is used to generate the array. This argument is typically the column that we want to use in order to populate the array.
Continue readingWhen we use psql
to write SQL queries in PostgreSQL, we’ll usually see the results presented as a table, with columns displayed vertically and rows running horizontally. But it is possible to change this so that the columns are displayed horizontally and the rows run vertically.
This can be useful for when the number of columns causes the results to be wider than our psql
display, and may cause the rows to wrap to the next line.
Here are five ways we can change the display to vertical output, otherwise known as expanded display.
Continue readingIn MySQL, GIPKs are invisible by definition. GIPK stands for generated invisible primary key, and it’s basically an invisible column automatically created by MySQL with a primary key constraint.
However, just because GIPKs are automatically created invisible, it doesn’t mean that we can’t “unhide” them – or make them visible.
We can make a GIPK visible just as we would make any other invisible column visible – use the ALTER TABLE
statement to set it to VISIBLE
.
In PostgreSQL we can create arrays with the ARRAY
constructor. An array constructor is an expression that builds an array value using values for its member elements.
PostgreSQL has a datestyle
setting that specifies the display format for date and time values, as well as the rules for interpreting ambiguous date input values.Â
We can check the current value of our datestyle
setting by running SHOW datestyle
.
PostgreSQL has a generate_subscripts()
function that generates a series comprising the valid subscripts of a given array.
We pass the array to the function, along with the dimension that we want to use. We also have the option of returning the series in reverse order.
Continue reading