Cristina Nogués
Cristina Nogués

Reputation: 33

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)

Upvotes: 0

Views: 290

Answers (1)

MatejG
MatejG

Reputation: 1423

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;

Upvotes: 1

Related Questions