// MySQL error reference

MySQL error 1091: Can't DROP; check that column/key exists

ALTER TABLE tries to drop a column, index or key that isn't on the table.

Error number
1091
Name
ER_CANT_DROP_FIELD_OR_KEY
SQLSTATE
42000
Category
Databases, tables and columns
Error message
Can't DROP '%s'; check that column/key exists

What it means

MySQL couldn't find the column or index named in DROP COLUMN, DROP INDEX or DROP FOREIGN KEY. For foreign keys, note that the constraint name and the index MySQL created for it can differ.

Common causes

  • The column or index was already dropped (a migration run twice).
  • Using the index name in DROP FOREIGN KEY, or the constraint name in DROP INDEX.
  • A typo.

How to fix it

  1. Check the real names of columns, indexes and foreign keys.

    SHOW CREATE TABLE orders;
  2. MySQL 8.0 doesn't support IF EXISTS for dropping columns or indexes, so check information_schema in your migration before dropping.

    SELECT constraint_name FROM information_schema.table_constraints
    WHERE table_schema = DATABASE() AND table_name = 'orders' AND constraint_type = 'FOREIGN KEY';

Related errors

More databases, tables and columns errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.