G
G
GrimJack2017-07-06 13:24:16
MySQL
GrimJack, 2017-07-06 13:24:16

Is it possible to set the field as auto increment after some time?

In general, there is a table, there are some data in it and there is an id field.
The previous developer did not make it auto-increment and when adding new records, he simply retrieved the last id and did +1.
Now we need to fix it without spending much time.
In fact, we know the maximum id in the table, can we "translate" id to autoincrement? Well, I know how to set the next value

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2017-07-06
@GrimJack

ALTER TABLE `yourtable` MODIFY COLUMN `id` INT auto_increment

PS: it would be nice to make a backup of the table / database before that

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question