K
K
kot-airplane2018-05-17 14:12:51
MySQL
kot-airplane, 2018-05-17 14:12:51

How to change field type in mysql?

There is a table with primary id tynyint id is missing.
When you try to change the field to smallint, it swears at errno 150, this is a foreign key error.
I was not going to change the keys at all, or rewrite the id, just the ability to add numbers further is needed.
How to change the field type in this case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2018-05-17
@alexey-m-ukolov

Since this field is used somewhere in other tables as a foreign key, then its type must also be changed there.

A
Antonio Solo, 2018-05-17
@solotony

a foreign key binds fields of the same type
:
1) delete the key
2) change the type of the field
3) change the type of the associated field
4) create a key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question