문제

I'm trying to add ZEROFILL to an auto-incremented primary ID field in a MySQL database. Here is the code (auto-generated by MySQL Workbench):

ALTER TABLE `database`.`table` CHANGE COLUMN `id` `id` INT(11) ZEROFILL NOT NULL AUTO_INCREMENT

This is the error I get:

Error Code: 1025. Error on rename of './database/#sql-2c8_cb' to './database/table' (errno: 150)

It appears that a temp table has been created and when the error occurs when the temp table is renamed with the original table name.

Any help would be great!

도움이 되었습니까?

해결책

If using InnoDB, check the status monitor (SHOW ENGINE INNODB STATUS) right after you execute the alter. It should tell you if it's because of the FK constraint. You may need to drop the constraints, alter the column and create them again.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top