简体   繁体   中英

Change datatype mysql

I try all of this options: Table Data Type Alter

And this is the output:

mysql> ALTER TABLE Xarxa CHANGE codiXarxa codiXarxa INT;
ERROR 1025 (HY000): Error on rename of './monxar/#sql-969_5b' to './monxar/Xarxa' (errno: 150)

mysql> ALTER TABLE Xarxa CHANGE codiXarxa codiXarxa INT(3);
ERROR 1025 (HY000): Error on rename of './monxar/#sql-969_5b' to './monxar/Xarxa' (errno: 150)

mysql> ALTER TABLE Xarxa MODIFY COLUMN codiXarxa codiXarxa INT(3);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'codiXarxa INT(3)' at line 1

mysql> alter table Xarxa modify codiXarxa int(3);
ERROR 1025 (HY000): Error on rename of './monxar/#sql-969_5b' to './monxar/Xarxa' (errno: 150)
ALTER TABLE Xarxa MODIFY codiXarxa INTEGER;

But it looks like errors you get are foreign key errors. If I'm right... drop foreign key first and than modify data type.

ALTER TABLE Xarxa DROP FOREIGN KEY codiXarxa;
ALTER TABLE Xarxa MODIFY codiXarxa INTEGER;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM