Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a few MySQL tables and I want to change the data type of some of the existing fields. The fields already have some single and multi-column indexes on them (all of which are type = "Normal").

I would like to know if changing the data types of any fields included in the existing indexes will have any effect on those indexes? Do I need to remove and re-create them for example or does MySQL handle that automatically?

share|improve this question

migrated from stackoverflow.com Mar 9 at 20:53

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 4 down vote accepted

Changing the data type of a column causes a table restructure, which will have the side-effect of rebuilding all indexes for the table (not only those referencing the column you altered, but all indexes in that table).

You don't need to drop or recreate the indexes yourself; it's already done by the time the ALTER TABLE finishes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.