MySQL 8.4Lab-verified · 2026-11-29

MySQL ERROR 1091 (42000): Can't DROP 'fax'; check that column/key exists

The column, index or foreign key named in ALTER TABLE ... DROP does not exist under that name.

MySQL 8.4.13
1091 (42000): Can't DROP 'fax'; check that column/key exists

Jump to a cause

  1. 01ALTER TABLE ... DROP COLUMN run a second time
  2. 02DROP INDEX with a guessed name
  3. 03DROP FOREIGN KEY with a guessed name

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4

ERROR 1091 (42000) comes from ALTER TABLE ... DROP when the thing to drop is not there. Either it was already dropped (a migration ran twice), or it exists under a different name, because MySQL named the index or foreign key automatically.

The message is the same for columns, indexes and foreign keys. 3 cases reproduced on MySQL 8.4.

01ALTER TABLE ... DROP COLUMN run a second time

fax was already dropped, and the same script ran again.

Setup
Setuprun as lab_a
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), fax VARCHAR(20));
ALTER TABLE users DROP COLUMN fax;
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
ALTER TABLE users DROP COLUMN fax;
✕ ERROR
ERROR 1091 (42000): Can't DROP 'fax'; check that column/key exists
Checkrun as lab_a
SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'users' ORDER BY ORDINAL_POSITION;
OUTPUT
+-------------+
| COLUMN_NAME |
+-------------+
| id          |
| name        |
+-------------+
2 rows in set (0.00 sec)

information_schema.COLUMNS shows only id and name. To make the script rerunnable, build the DROP only when the column exists: SET @ddl = IF((SELECT COUNT(*) ... COLUMN_NAME = 'fax') > 0, 'ALTER TABLE users DROP COLUMN fax', 'SELECT ...') then PREPARE / EXECUTE. Here it printed fax already dropped instead of failing.

After the fixrun as lab_a
SET @ddl = IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'users' AND COLUMN_NAME = 'fax') > 0,
  'ALTER TABLE users DROP COLUMN fax',
  'SELECT ''fax already dropped'' AS msg');
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
✓ SUCCESS
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Statement prepared

+---------------------+
| msg                 |
+---------------------+
| fax already dropped |
+---------------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

02DROP INDEX with a guessed name

The UNIQUE was declared without a name (UNIQUE (email)), so MySQL named the index after the column: email. There is no index uk_members_email.

Setup
Setuprun as lab_a
CREATE TABLE members (id INT PRIMARY KEY, email VARCHAR(100), UNIQUE (email));
OUTPUT
Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
ALTER TABLE members DROP INDEX uk_members_email;
✕ ERROR
ERROR 1091 (42000): Can't DROP 'uk_members_email'; check that column/key exists
Checkrun as lab_a
SELECT INDEX_NAME, COLUMN_NAME, NON_UNIQUE FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'members';
OUTPUT
+------------+-------------+------------+
| INDEX_NAME | COLUMN_NAME | NON_UNIQUE |
+------------+-------------+------------+
| email      | email       |          0 |
| PRIMARY    | id          |          0 |
+------------+-------------+------------+
2 rows in set (0.00 sec)

information_schema.STATISTICS lists the real index names: email and PRIMARY. ALTER TABLE members DROP INDEX email; succeeds.

After the fixrun as lab_a
ALTER TABLE members DROP INDEX email;
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

03DROP FOREIGN KEY with a guessed name

The foreign key was declared without CONSTRAINT name, so MySQL named it orders_ibfk_1 (table name + _ibfk_ + number).

Setup
Setuprun as lab_a
CREATE TABLE customers (id INT PRIMARY KEY);
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, FOREIGN KEY (customer_id) REFERENCES customers (id));
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
ALTER TABLE orders DROP FOREIGN KEY fk_orders_customer;
✕ ERROR
ERROR 1091 (42000): Can't DROP 'fk_orders_customer'; check that column/key exists
Checkrun as lab_a
SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'orders';
OUTPUT
+-----------------+-----------------+
| CONSTRAINT_NAME | CONSTRAINT_TYPE |
+-----------------+-----------------+
| PRIMARY         | PRIMARY KEY     |
| orders_ibfk_1   | FOREIGN KEY     |
+-----------------+-----------------+
2 rows in set (0.00 sec)

information_schema.TABLE_CONSTRAINTS shows orders_ibfk_1 (FOREIGN KEY). Dropping that name works. SHOW CREATE TABLE afterwards shows the FK is gone but the index customer_id that came with it is still there; drop it separately with DROP INDEX if you no longer need it.

After the fixrun as lab_a
ALTER TABLE orders DROP FOREIGN KEY orders_ibfk_1;
SHOW CREATE TABLE orders\G
✓ SUCCESS
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

*************************** 1. row ***************************
       Table: orders
Create Table: CREATE TABLE `orders` (
  `id` int NOT NULL,
  `customer_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customer_id` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
1 row in set (0.00 sec)

FAQ

How do I fix MySQL error 1091 Can't DROP?

Check the real name first: information_schema.COLUMNS for columns, STATISTICS for indexes, TABLE_CONSTRAINTS for foreign keys. Then drop by that name, or skip if it is already gone.

Does MySQL 8.4 support DROP COLUMN IF EXISTS?

No. Check information_schema.COLUMNS and run the ALTER through PREPARE / EXECUTE only when the column exists.

What is the name of a foreign key I created without a name?

MySQL names it <table>_ibfk_<n>, for example orders_ibfk_1. Look it up in information_schema.TABLE_CONSTRAINTS or SHOW CREATE TABLE.

Why does dropping a foreign key leave an index behind?

MySQL created an index on the FK column when the key was added. DROP FOREIGN KEY removes only the constraint; the index (here customer_id) stays.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13