views:

19

answers:

2

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 index on the same field. Some Indexes are missing, And mainly 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 ALTER TABLE and will add the relevant indexes.

Is there a way to drop all indexes from a table?

10x.

+1  A: 

If you have phpmyadmin or any similar tool you can do that very easily graphically.

Or for every index do something like

ALTER TABLE  `table` DROP INDEX  `NameIndex`

You can get the indexes with

SHOW INDEX FROM `table`
Loïc Février
+1  A: 

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.

Joe Hopfgartner
@Joe Hopfgartner - first thanks for the answer. second i am accepting answers as the answer really answers and gives solution for the question. anyhow i can write the script myself but thanks for offering. wish there would be a way to do so though (dropping all indexes).
aviv
okay... thats right. 54% just looked a bit few to me but if its like this its totally okay. loic posted the command to list indexes, good luck with your script
Joe Hopfgartner