ALTER TABLE
.
ALTER TABLE
.
ALTER TABLE
changes a table to the current character set.
If you get a duplicate key error during ALTER TABLE
, then the cause
is either that the new character sets maps two keys to the same value
or that the table is corrupted, in which case you should run
REPAIR TABLE
on the table.
If ALTER TABLE
dies with an error like this:
Error on rename of './database/name.frm' to './database/B-a.frm' (Errcode: 17)
the problem may be that MySQL has crashed in a previous ALTER
TABLE
and there is an old table named `A-something' or
`B-something' lying around. In this case, go to the MySQL data
directory and delete all files that have names starting with A-
or
B-
. (You may want to move them elsewhere instead of deleting them.)
ALTER TABLE
works the following way:
If something goes wrong with the renaming operation, MySQL tries to undo the changes. If something goes seriously wrong (this shouldn't happen, of course), MySQL may leave the old table as `B-xxx', but a simple rename on the system level should get your data back.