In MariaDB, you can use the SUBSTRING_INDEX()
function to return everything before or after a certain character (or characters) in a string.
Author: Ian
Get the Size of All Databases in PostgreSQL (psql)
When using psql with PostgreSQL, we can use the \list+
command to return information about all databases on the server.
We can also use the short form (\l+
) to achieve the same result.
Concatenate a String and a Number in SQL
In most cases, concatenating a string and a number in SQL is no different to concatenating two strings.
Most DBMSs will concatenate the string and number as if they were both strings. This is because the number is usually converted to a string before the concatenation operation.
Continue readingHow to List All Views in Oracle Database
You can use the following views to return a list of views in Oracle Database.
Continue readingHow to Change the Table Border Style in the psql Query Results
When using psql
to run queries against PostgreSQL, we can use the \pset border
and \pset linestyle
commands to change the border of the table that displays our results.
Oracle GROUP_CONCAT() Equivalent
Some RDBMSs have a GROUP_CONCAT()
function that allows you to return a query column as a delimited list (for example, a comma separated list). MySQL and MariaDB are two that have such a function.
PostgreSQL and SQL Server have similar functions called STRING_AGG()
.
Oracle, on the other hand, has the LISTAGG()
function that does pretty much the same thing (and perhaps more).
So you could say that LISTAGG()
is Oracle’s GROUP_CONCAT()
equivalent.
How to Check if a Table Exists in SQLite
In SQLite, we can query the sqlite_schema
table to find out whether a given table exists.
Prior to SQLite version 3.33.0, this table was referred to as sqlite_master
(it can still be referred to as such in subsequent releases for backwards compatibility).
How to Format Numbers with Commas in MySQL
We can use the FORMAT()
function in MySQL to format numbers into a more human readable format.
The function returns the number as a formatted string. It adds thousands separators and a decimal separator as required, and rounds the results to the given decimal position.
Continue readingHow to Export Oracle Query Results to a JSON File when using SQLcl
When using SQLcl with Oracle Database, you can export your query results to a JSON file with the SPOOL
command.
4 Ways to Check if a Table Exists in MariaDB
Here are four ways to check whether or not a table exists in a MariaDB database.
Continue reading