I have a MySQL database that runs for some time now with many changes on it. Lately I looked over it and I noticed that in some cases I have doubled the index on the same field. Some Indexes are missing, and in general there is a huge mess in all the indexes.
I wants to drop all indexes from a table. Later on I have a prepared script that will run ALTER TABLE
and add the relevant indexes.
Is there a way to drop all indexes from a table?
no there isnt a command. you can however write a script that shows all databases, shows all tables inside thowe databases, shows all indexes inside those tables and drops them all. but i'n not gonna write that for you if you don't start accepting some answers. you can also use phpmyadmin or another graphical tool to select this neat "check all" box for every table.
If you have phpmyadmin or any similar tool you can do that very easily graphically.
Or for every index do something like
You can get the indexes with
Simple script:
In Ruby on Rails I do this: