Here are five ways to check whether or not a table exists in a MySQL database.
Continue readingAuthor: Ian
How to Return Query Results as a Comma Separated List in PostgreSQL
In Postgres, we can use the STRING_AGG()
function to transform our query results into a comma separated list.
Instead of each value being output in a separate row (as with any regular query), the values are output to a single row, separated by a comma (or some other delimiter of our choosing).
Continue readingHow to Generate a Random Integer Within a Range in MariaDB
MariaDB includes a RAND()
function that returns a random number. More precisely, it returns a DOUBLE
precision floating point value v
in the range 0 <= v < 1.0
.
This is great, but what if you want to generate an integer within a larger range – and a range that you specify?
Fortunately, there’s an easy technique for doing this.
Continue readingFix: “operator does not exist: integer || integer” in PostgreSQL
If you get the “operator does not exist: integer || integer” error in PostgreSQL, it’s probably because you’re trying to concatenate two numbers.
If you really want to concatenate two numbers, the easiest way to overcome this issue is to cast at least one of them to a string data type first.
Another way to do it is to use the CONCAT()
function.
2 Ways to List all Stored Procedures in MySQL
Below are two options for returning a full list of stored procedures in MySQL.
Continue readingRR vs YY in Oracle
When formatting dates in Oracle Database, we have the option of using RR
and YY
to return a two digit year.
These two format elements are similar. The difference is in how they interpret two digits years.
We also have the option of using RRRR
and YYYY
when returning four digit years.
How to Generate INSERT Statements from a Query when using SQLcl (Oracle)
When using SQLcl with Oracle Database, you can set SQLFORMAT
to insert
in order to output the query results as INSERT
statements.
Fix: “BACKUP LOG cannot be performed because there is no current database backup.” in SQL Server/SQL Edge
If you’re trying to back up the transaction logs in a SQL Server or SQL Edge database, but you get an error that states BACKUP LOG cannot be performed because there is no current database backup, you’ll need to perform at least one full backup of the database before you attempt to back up the transaction logs.
Continue reading2 Ways to Get the Size of a Database in PostgreSQL
Below are two ways to return the size of a specific database in PostgreSQL.
Continue readingSubtract Microseconds from a Datetime Value in MariaDB
Here are some options for subtracting one or more microseconds from a datetime expression in MariaDB.
Continue reading