Reputation: 686
I recently noticed that there are several bigint type fields in one of my databases that could be replaced with type "int". The problem is that the database is already online and in use and also that there are foreign keys in action, so when I try changing the data type in the offline DB, mysql won't let me and produces the error message: "#1025 - Error on rename of (...)".
So how can I change these fields while keeping the foreign keys happy? (and not wiping out the existing DB!)
Upvotes: 3
Views: 4052
Reputation: 31
You can alter a column from BIGINT to INT as long as there is not any data in the column that would not fit into the smaller INT datatype.
ALTER TABLE mytable MODIFY COLUMN mycolumn INT(11);
Upvotes: 3
Reputation: 11232
You could try:
DROP
and CREATE
).Upvotes: 0
Reputation: 1106
You can't reduce the size of field when it holds data. You can only expand them. What you can do is export all the data, disable the keys, empty the tables, change the field sizes & import the data again.
Upvotes: -1