Ever use something like phpMyAdmin?  Ever add and/or remove some columns to a table, but then realize that the order of the columns aren’t really the way you’d like them?

This has bothered me ever since I started using phpMyAdmin.  To the best of my knowledge there isn’t a way to fix this from within the software.  However, it’s quite trivial to do it via regular SQL:


ALTER table `table_name`
MODIFY COLUMN `column_name` your_data_type
AFTER `other_column_name`

And by golly it works!

Found at Treble Click: Reorder mysql table columns via a Google search.

One Response to “Reorder Mysql Table Columns”

  1. Joshua Works Says:

    Nice tip! I’ve always struggled with the same thing. I hate when columns aren’t in the right order.

    Anyway, thought I’d also mention a Mac OS X MySQL tool called Querious ($25), which I’m really liking as a replacement for phpMyAdmin. It lets you drag & drop columns, inline rename columns and data, open multiple tabs of databases, etc. Very slick. Highly recommended.

Drop Some Knowledge On Us…