-
-
Notifications
You must be signed in to change notification settings - Fork 238
Closed
Labels
Description
I encountered an unexpected syntax error while attempting to add a new column to an existing table using the AFTER clause in an ALTER TABLE statement.
Steps to Reproduce
- Create a table named
table1with the following structure:
CREATE TABLE `table1` (
`id` int NOT NULL,
`value` int NOT NULL,
PRIMARY KEY (`id`)
)- Attempt to add a new column
value2after thevaluecolumn:
ALTER TABLE table1 ADD COLUMN value2 TEXT AFTER value;Expected Behavior
The new column value2 should be added after the value column without any errors.
Actual Behavior
The following error is returned:
ERROR 1105 (HY000): syntax error at position 54 near 'value'
Additional Information
- Removing the
AFTER valueclause allows the statement to execute successfully:
ALTER TABLE table1 ADD COLUMN value2 TEXT;- Using a different existing column in the
AFTERclause, such asAFTER id, also works as expected:
ALTER TABLE table1 ADD COLUMN value2 TEXT AFTER id;- The original statement with
AFTER valueexecutes successfully in MySQL 8.0.