MySQL 8.4 Release Notes
B.3.6.1 ALTER TABLE 问题
If you get a duplicate-key error when using ALTER TABLE
to change the character set or collation of a character column, the cause is either that the new column collation maps two keys to the same value or that the table is corrupted. In the latter case, you should run REPAIR TABLE
on the table. REPAIR TABLE
works for MyISAM
, ARCHIVE
, and CSV
tables.
If you use ALTER TABLE
on a transactional table or if you are using Windows, ALTER TABLE
unlocks the table if you had done a LOCK TABLE
on it. This is done because InnoDB
and these operating systems cannot drop a table that is in use.