[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Move a column
David Lidström writes:
> Hi!
>
> Is it not possible to move a mysql column to after another existing
> Column by using the CHANGE statement in ALTER TABLE?
>
> ALTER TABLE enum_test CHANGE ostron ostron int(4) NULL DEFAULT '0'
> AFTER newCol_2
Moving oysters around, eh? :-)
As far as I know, there is no way to move columns around, although you
can do it by dropping the column and recreating it in a different
position. the workaround is to CREATE TABLE ... SELECT ... and then
remove the old table and rename the new one.
The only downside to this is that for a brief moment your table will
not be there. Oh, and I suspect you'll get into all sorts of problems
if you're using foreign keys.
Generally, I avoid trying to move columns about, if only so that a
dump of the structure won't be different without there being a real
(i.e., significant) difference. Also, the order of the columns might
have some archeological curiosity value. ;-)
//C - listening to Iron Maiden while drinking tea.
--
Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
carl@xxxxxxxxxx | http://pixelmagic.dyndns.org/~cirdan/
Amiga user since '89, and damned proud of it too.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <mysql-thread92258@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
This mailing list archive is a service of Copilot Consulting.