I have a table named provider. In the provider table, I have a column named provider. The character encoding of this column is currently latin1:
`provider` varchar(60) CHARACTER SET latin1 NOT NULL DEFAULT '',
Several other tables FK reference provider.provider also. How would I change the encoding to be utf8 and cascade all the changes to the foreign key references? The equivalent of:
ALTER TABLE provider MODIFY
provider VARCHAR (60)
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
But for all columns that FK reference it also. (Note: doing the above on its own errors.)
You cannot cascade ALTER TABLE changes. You need to do each table separately. The manual states that the charset and collation of foreign key references must be the same. Thus, if you just try to change the collation of the parent table before changing the child table (or vice-vesa), MySQL will complain with a horrendously ambiguous error (errno 150). Thus, you must disable foreign key checks before altering the tables:
SET foreign_key_checks = 0;
— DO ALTERS —
SET foreign_key_checks = 1;
Should work.