alter table add ... before `code`?

Hailwood picture Hailwood · Aug 4, 2010 · Viewed 21.5k times · Source

ALTER TABLE tada_prod.action_6_weekly ADD COLUMN id INT NULL AUTO_INCREMENT UNIQUE AFTER member_id;

works,

so i thought, to add the column as the first column i could do

ALTER TABLE `tada_prod`.`action_6_weekly`     ADD COLUMN `id` INT NULL AUTO_INCREMENT UNIQUE BEFORE `code`;

but i get a syntax error, what is the correct syntax?

Answer

Ben Hoffstein picture Ben Hoffstein · Aug 4, 2010
ALTER TABLE `tada_prod`.`action_6_weekly`
ADD COLUMN `id` INT NULL AUTO_INCREMENT UNIQUE FIRST;