How to change MySQL Primary Key from signed to unsigned?
In my MySQL InnoDB Database with foreign keys I accidentally made some of my primary keys signed instead of unsigned as I want them to be.
Now I want to change it with a ALTER TABLE statement but it does not work:
ALTER TABLE `users` CHANGE `id` `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT
Error on rename of './db_dev/#sql-478_3' to './db_dev/users' (errno: 150)
I don't understand why. I am working with Foreign Keys and tried using a
SET foreign_key_checks = 0;
Statement before executing the ALTER TABLE from above. Doesn't work either. Notice: All my tables are still empty. There's no data in it yet.
Since the Database has a lot of tables it would be much work to drop all the foreign keys and then manually add them again. (if this should be the reason).
This field is used in foreign key(s). To change this field in MySQL, you should perform these steps:
- Drop all related foreign keys
- Modify field
- Recreate all dropped foreign keys
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]