1060ERRORTier 2 — Caution✅ HIGH confidenceDuplicate column name
What this means
Error 1060 (SQLSTATE 42S21) is raised by ALTER TABLE or CREATE TABLE when two or more columns in the same table definition share identical names. Column names must be unique within a table.
Why it happens
- 1ALTER TABLE ADD COLUMN specifies a name that already exists
- 2CREATE TABLE DDL has a duplicate column name — often a copy-paste error
- 3A migration script runs twice without a guard
How to reproduce
Adding a column that already exists to a table.
ALTER TABLE users ADD COLUMN email VARCHAR(255);
-- 'email' column already exists on users tableFix 1: Check if column exists before adding
In migration scripts that may run more than once.
-- Check first:
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'users'
AND COLUMN_NAME = 'email';
-- Or in MariaDB 10.3.3+ use IF NOT EXISTS:
ALTER TABLE users ADD COLUMN IF NOT EXISTS email VARCHAR(255);Why this works
ALTER TABLE … ADD COLUMN IF NOT EXISTS is a MariaDB extension that silently skips the ADD if the column already exists, making migrations idempotent.
What not to do
Run migration scripts without idempotency guards
Why it's wrong: Scripts that run twice break deployments with this error.
Version notes
MariaDB 10.3.3+ADD COLUMN IF NOT EXISTS is supported. MySQL does not support this syntax.Sources
📚 Official docs: https://mariadb.com/kb/en/alter-table/
🔧 Source ref: MariaDB Server error code 1060 / ER_DUP_FIELDNAME
📖 Further reading: MariaDB ALTER TABLE
📖 Further reading: MariaDB IF NOT EXISTS for columns
Confidence assessment
✅ HIGH confidence
Stable.
See also
🔗 Related errors
📄 Reference pages