1091: Can't DROP 'x'; check that column/key exists
MySQLWhat does it mean?
The column, index or foreign key being dropped with ALTER TABLE does not exist. A nonexistent object cannot be dropped.
Why does it happen?
Giving a nonexistent object name in DROP COLUMN/INDEX/FOREIGN KEY; a misspelled name; the object already dropped; confusing the foreign key name with the index name; a migration run a second time.
How to fix it
Verify the object's real name: SHOW CREATE TABLE my_table; or SHOW INDEX FROM my_table; Drop it using the correct name. For a foreign key use its symbol name: ALTER TABLE my_table DROP FOREIGN KEY fk_name; MySQL has no DROP COLUMN IF EXISTS syntax (only MariaDB does); in idempotent migrations, first check that the column exists via information_schema.columns: SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'my_table' AND column_name = 'my_column';
More from this engine
- 1071Specified key was too long; max key length is 767 bytes
- 1050Table already exists
- 1051Unknown table 'x'
- 1093You can't specify target table 'x' for update in FROM clause
- 1305PROCEDURE does not exist
- 1227Access denied; you need (at least one of) the PRIVILEGE
- 3730Cannot drop table referenced by a foreign key constraint