Move MySQL Field???

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Move MySQL Field???

Post by Mr. Tech »

Is there a way to move a mysql field? I tried this but it didn't work:

ALTER TABLE `db`.`test` MOVE `field1` AFTER `field2`

Is this possible? If you don't know do you know where I can find out?

Thanks
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

according to phpmyadmin, its
ALTER TABLE `newsusers` CHANGE `startdate` `startdate` TIMESTAMP( 14 ) DEFAULT NULL

http://www.mysql.com/doc/en/ALTER_TABLE.html

abotu 1/3 of the way down
You can rename a column using a CHANGE old_col_name create_definition clause. To do so, specify the old and new column names and the type that the column currently has. For example, to rename an INTEGER column from a to b, you can do this:
mysql> ALTER TABLE t1 CHANGE a b INTEGER;
according tot he mysql website theres no such thing as ALTER - MOVE. So im assuming what you are trying to do is rename your collumns (if you are moving then probably the easiest thing to do would be to rename the collumn and then recreate the old collumn)
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

OK thanks :D
Post Reply