A
A
Arthur2020-04-10 15:31:17
MySQL
Arthur, 2020-04-10 15:31:17

How to assign unique id to existing rows?

There is a my_table table and an id column. The rows are already filled in it and all rows have id=0. How can I uniqueize all ids by giving them the value 1, 2, 3... and so on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arthur, 2020-04-10
@arturweb01

Solution:
We create a new column with type int, set AUTO_INCREMENT and Index "UNIQUE", after that we delete the old id column and rename the column we created to id.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question