alter-table-problems.md 792 字节
Newer Older
茶陵後's avatar
茶陵後 已提交
1 2 3 4 5 6 7 8
#### B.3.6.1 Problems with ALTER TABLE

[]()[]()[]()[]()

 If you get a duplicate-key error when using [`ALTER TABLE`](alter-table.html) 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`](repair-table.html) on the table. [`REPAIR TABLE`](repair-table.html) works for `MyISAM`, `ARCHIVE`, and `CSV` tables.

 If you use [`ALTER TABLE`](alter-table.html) on a transactional table or if you are using Windows, [`ALTER TABLE`](alter-table.html) unlocks the table if you had done a [`LOCK TABLE`](lock-tables.html) on it. This is done because `InnoDB` and these operating systems cannot drop a table that is in use.