DatabaseStatusSyntax FamilyMin Version
PostgreSQL full if-exists 9.1
MySQL full if-exists -
MariaDB full if-exists -
Oracle partial if-exists 23c
SQL Server workaround object-id-check -
SQLite full if-exists -
Redshift full if-exists -
DB2 partial if-exists 11.1
Snowflake full if-exists -
BigQuery full if-exists -

Compare Databases

Database Details

PostgreSQL full
CREATE TABLE IF NOT EXISTS users (
  id SERIAL PRIMARY KEY,
  email TEXT NOT NULL
);

DROP TABLE IF EXISTS users;
  • Broad coverage: CREATE IF NOT EXISTS on tables, indexes, schemas, sequences; DROP IF EXISTS on most object types.
  • ALTER TABLE ADD COLUMN IF NOT EXISTS since 9.6.
  • CREATE TABLE IF NOT EXISTS only checks the name — it does not reconcile column definitions against the existing table.
MySQL full
CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • Available on CREATE / DROP for TABLE, DATABASE, INDEX, VIEW, and DROP PROCEDURE.
  • CREATE TABLE IF NOT EXISTS emits a warning (not an error) when the table already exists.
MariaDB full
CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • Same IF EXISTS / IF NOT EXISTS coverage as MySQL, plus CREATE OR REPLACE on tables, views, triggers, and procedures for idempotent DDL.
Oracle partial
CREATE TABLE IF NOT EXISTS users (
  id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  email VARCHAR2(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • Added in 23c on CREATE TABLE, DROP TABLE, and several other DDL statements.
  • Pre-23c, use PL/SQL with ORA-00942 / ORA-00955 exception handling, or pre-check USER_TABLES.
SQL Server workaround
IF OBJECT_ID('dbo.users', 'U') IS NULL
BEGIN
  CREATE TABLE dbo.users (
    id INT IDENTITY PRIMARY KEY,
    email NVARCHAR(255) NOT NULL
  );
END;

DROP TABLE IF EXISTS dbo.users;
  • DROP ... IF EXISTS on tables, indexes, and procedures arrived in 2016.
  • No CREATE TABLE IF NOT EXISTS. The T-SQL idiom for conditional CREATE is IF OBJECT_ID(name, 'U') IS NULL BEGIN CREATE TABLE ... END.
SQLite full
CREATE TABLE IF NOT EXISTS users (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL
);

DROP TABLE IF EXISTS users;
  • Long-standing. Available on CREATE / DROP for tables, indexes, views, and triggers.
Redshift full
CREATE TABLE IF NOT EXISTS users (
  id INT IDENTITY PRIMARY KEY,
  email VARCHAR(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • Same syntax as PostgreSQL across CREATE / DROP for tables, views, and related objects.
DB2 partial
CREATE TABLE IF NOT EXISTS users (
  id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  email VARCHAR(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • CREATE TABLE IF NOT EXISTS arrived in 11.1; DROP TABLE IF EXISTS in recent versions.
  • Pre-11.1, check SYSCAT.TABLES before running DDL.
Snowflake full
CREATE TABLE IF NOT EXISTS users (
  id INT AUTOINCREMENT PRIMARY KEY,
  email VARCHAR(255) NOT NULL
);

DROP TABLE IF EXISTS users;
  • Available on CREATE, DROP, and ALTER across every object type (TABLE, VIEW, SCHEMA, DATABASE, WAREHOUSE, ...).
BigQuery full
CREATE TABLE IF NOT EXISTS users (
  id INT64,
  email STRING NOT NULL
);

DROP TABLE IF EXISTS users;
  • Available on CREATE / DROP for tables, views, and related objects.