MySQL Error 1060: Duplicate Column Name (42S21)
Fix MySQL Error 1060 (42S21) by checking the table definition before adding or redefining a column, and identify duplicate schema migrations.
On this page
MySQL Error 1060 (42S21, ER_DUP_FIELDNAME) means a CREATE TABLE or ALTER TABLE statement defined the same column name more than once. The message is:
ERROR 1060 (42S21): Duplicate column name 'status'
The MySQL 8.4 error reference identifies this as a duplicate field name. It is a schema-definition error; it does not mean that two rows contain the same value.
Inspect the table before changing it
If the error came from an ALTER TABLE, inspect the exact table named in the statement:
SHOW CREATE TABLE `app_db`.`orders`;
SHOW COLUMNS FROM `app_db`.`orders`;
Check whether the column already exists and compare its type, default, nullability, and other attributes with the definition you intended. If you expected a different database, verify the connection with SELECT DATABASE() or qualify the table name.
Choose the fix that matches your intent
Reuse a column that is already correct
If the column exists with the definition the application needs, remove the repeated ADD COLUMN from the script or migration. Do not rerun an already-applied migration just to bring the database up to date.
Modify an existing column
If the column exists but its definition must change, use an ALTER TABLE operation such as MODIFY COLUMN rather than adding another column with the same name:
ALTER TABLE `app_db`.`orders`
MODIFY COLUMN `status` VARCHAR(30) NOT NULL DEFAULT 'pending';
Supply every attribute that should remain. MySQL does not automatically preserve omitted column attributes in a MODIFY or CHANGE definition. Review the current definition and consider how existing values will be converted before running a schema change. See the MySQL ALTER TABLE guide.
Remove a duplicate definition from a new table
If a CREATE TABLE statement lists the same column twice, remove or rename the duplicate definition. For example, keep one status column in the table definition instead of declaring it in two places.
Make migrations safe to rerun
If a deployment or setup script attempted the same ADD COLUMN more than once, check the migration history and the live schema. Apply each schema change once, and have migration tooling record which changes completed. CREATE TABLE IF NOT EXISTS does not make an ALTER TABLE ADD COLUMN repeatable and does not add missing columns to an existing table.
For ADD COLUMN syntax and examples, see the MySQL add-column tutorial. Error 1060 is different from Error 1050, where the table itself already exists, and Error 1062, where row data duplicates a unique key. Browse more fixes in MySQL error troubleshooting.