Skip to content

Instantly share code, notes, and snippets.

@rpivo
Last active June 15, 2021 12:26
Show Gist options
  • Save rpivo/24c3db3a207ed93cbad87e9cd8192937 to your computer and use it in GitHub Desktop.
Save rpivo/24c3db3a207ed93cbad87e9cd8192937 to your computer and use it in GitHub Desktop.
Create a MySQL Table Only if It Doesn't Already Exist

Create a MySQL Table Only if It Doesn't Already Exist

The following statement creates a MySQL table Products only if it doesn't yet exist. If the table does already exist, then the statement will do nothing.

CREATE TABLE IF NOT EXISTS Products (
  product_id int,
  low_fats ENUM('Y', 'N'),
  recyclable ENUM('Y', 'N')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment