tags:

views:

25

answers:

1

In MySQL 5.0.51b on my Mac, ordinals beyond FIRST fail, as does BEFORE.

So,

ALTER TABLE my_contacts
ADD COLUMN phone VARCHAR(10) FOURTH;

fails altogether, as would

ALTER TABLE my_contacts
ADD COLUMN phone VARCHAR(10) BEFORE email;

Do these work with any other flavors or versions of MySQL?

+3  A: 

I doubt they work any differently on other OS installations as the mysql docs for alter table in 5.0 don't offer a BEFORE modifier. I recommend using AFTER instead (or FIRST if you're inserting this as the first column in the table).

ALTER TABLE my_contacts
ADD COLUMN phone VARCHAR(10) AFTER some_column_name;
Jarret Hardie
Ah, thanks! Just FIRST and AFTER work. Okay, makes sense.
lynn
np... good question. I had to look up the docs myself because, frankly, I would have also sworn that there was a BEFORE modifier :-)
Jarret Hardie