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).

Read more

SHOW DATABASES Equivalent in SQL Server – sp_databases

There are several ways to show a list of databases in SQL Server. Probably the easiest way is to use the sp_databases stored procedure.

The sp_databases stored procedure is a kind of SQL Server equivalent to the SHOW DATABASES command that can be used with DBMSs such as MySQL and MariaDB. OK, maybe they aren’t strictly equivalents, but based on their ease of use, they could be viewed as such from a user’s perspective.

Read more

Get the Size of a Database in MariaDB

In MariaDB, we can query the information_schema.tables table to check the size of a database.

This table returns information about the tables and views in each database on the server. We can group the results and return the aggregate amounts for each database.

Read more

Find a String within a String in SQL

Most of the major DBMSs provide us with a way to find a string within a string using SQL. By this, I mean use a SQL query to find the position of a substring within a string.

There are several SQL functions that allow us to do this, including INSTR(), LOCATE(), POSITION(), and CHARINDEX(). The function you use will depend on your DBMS, and possibly whether or not you need to specify a starting position.

Read more