Question

Today I tried to reorder a column of a table using phpMyAdmin (as I have done many times before). Although the result was displayed as successful no reordering effectively happened.

It appears the problem is caused by using InnoDB as storage engine which is the default value from MySQL 5.5 onward. When I changed back to myIsam the problem was solved. It clarified why it was working on some tables.

Is this a solvable mySQL problem? Or is this regular expected behavior for InnoDB ? In the latter case phpMyAdmin should perhaps be adapted to not offer the functionality while using InnoDB.

MySQL: 5.5.29 phpMyAdmin: 4.0.4

Was it helpful?

Solution

If by ...reordering column... you meant

 ALTER TABLE ... ORDER BY ...

then for InnoDB table that has a PRIMARY or UNIQUE KEY it doesn't work. It's by design:

ALTER TABLE
ORDER BY does not make sense for InnoDB tables that contain a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index). InnoDB always orders table rows according to such an index if one is present.

On the other hand if you don't have PRIMARY or UNIQUE KEY in your table, which is highly unlikely, then MySQL will allow you to change the order.

Here is SQLFiddle demo that demonstrates that behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top