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
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 inDROP INDEX. - A typo.
How to fix it
-
Check the real names of columns, indexes and foreign keys.
SHOW CREATE TABLE orders;
-
MySQL 8.0 doesn't support
IF EXISTSfor dropping columns or indexes, so checkinformation_schemain 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
1049Unknown database1046No database selected1054Unknown column in field list1146Table doesn't exist1050Table already exists1060Duplicate column name1305Function or procedure does not exist1442Trigger can't update its own table
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.
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.