Does dropping a table in MySQL also drop the indexes?

Teflon Ted picture Teflon Ted · May 20, 2009 · Viewed 19.3k times · Source

It's not explicitly mentioned in the documentation (http://dev.mysql.com/doc/refman/6.0/en/drop-table.html). I ask because I just saw a curious database migration in a Rails project where the developer was removing all the indexes before dropping the table, and that seemed unnecessary.

Answer

AvatarKava picture AvatarKava · May 20, 2009

Yes, it does.

However, if you have foreign key constraints such as RESTRICT that ensure referential integrity with other tables, you'll want to drop those keys prior to dropping or truncating a table.