patternsqlMinor
what effect does changing the data type of an existing indexed field have on the index?
Viewed 0 times
effectindexfieldthewhattypeindexeddoesexistingchanging
Problem
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?
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?
Solution
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.
You don't need to drop or recreate the indexes yourself; it's already done by the time the ALTER TABLE finishes.
Context
StackExchange Database Administrators Q#60526, answer score: 7
Revisions (0)
No revisions yet.