In PostgreSQL, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
Tag: tables
Check if a Table Exists in Oracle
In Oracle Database, there are a number of views that we can query to find out whether a table exists.
Continue readingPostgreSQL DESCRIBE TABLE Equivalent
Some DBMSs such as Oracle, MySQL, and MariaDB have a DESCRIBE
command that returns information about tables and views. It goes DESCRIBE table
where table is the name of the table or view, and it can also be followed by a column name if you only want information about a specific column.
PostgreSQL doesn’t have a DESCRIBE TABLE
command as such, but there are alternatives.
DROP TABLE IF EXISTS in SQLite
In SQLite, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
PRAGMA table_list in SQLite
In SQLite, the table_list
pragma returns information about the tables and views in the schema.
It was first introduced in SQLite version 3.37.0 (released on 2021-11-27).
Continue readingDROP TABLE IF EXISTS in MariaDB
In MariaDB, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
Oracle DROP TABLE IF EXISTS Alternatives
The very useful DROP TABLE IF EXISTS
syntax was finally introduced in Oracle Database – Oracle Database 23c to be precise. This syntax allows us to run a DROP TABLE
statement without getting an error if the table doesn’t exist.
Earlier versions of Oracle don’t support the IF EXISTS
clause. Therefore, if we want to avoid any nasty errors resulting from trying to drop a non-existent table, we need to do a bit of extra work.
Below are three options for dropping a table if it exists in Oracle.
Continue readingDROP TABLE IF EXISTS in MySQL
In MySQL, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
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).
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