DBAtlas · Database operations atlas

1050: Table already exists

MySQL

What does it mean?

The table being created already exists. CREATE TABLE failed because a table with the same name is present.

Why does it happen?

Re-creating an existing table; a script run twice; migrations applied again; another object (a view) using the same name.

How to fix it

Use IF NOT EXISTS to create the table only if it is absent: CREATE TABLE IF NOT EXISTS my_table (...); If you really want to re-create it, drop it first: DROP TABLE IF EXISTS my_table; List existing tables: SHOW TABLES; Make migrations safe to re-run (idempotent).

Open in DBAtlas →

More from this engine