1166
MySQLERRORCommonDDLHIGH confidence
Incorrect column name
Production Risk
Low — DDL fails; no data loss.
What this means
ER_WRONG_COLUMN_NAME (1166, SQLSTATE 42000) is raised when a column name contains invalid characters or is otherwise syntactically incorrect.
Why it happens
- 1Column name contains a null byte or other control character
- 2Column name is empty
- 3Column name exceeds 64 characters
How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE t (`col name` INT);
expected output
ERROR 1166 (42000): Incorrect column name 'col name'
Fix
Use valid identifier characters in column names
WHEN Always.
Use valid identifier characters in column names
CREATE TABLE t (col_name INT);
Why this works
Column names should use letters, digits, and underscores; spaces require backtick quoting and are generally discouraged.
What not to do
✕ Use column names with spaces even when backtick-quoted
While technically valid with quoting, space-containing names require consistent quoting everywhere they are referenced, creating maintenance burden.
Sources
Official documentation ↗
MySQL 8.0 — 1166 ER_WRONG_COLUMN_NAME
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev