M
M
McFkr2019-02-06 17:14:56
MySQL
McFkr, 2019-02-06 17:14:56

How to add a second autoincrement and populate the field?

There is a completed table. You need to add a field that will be an auto-increment. This field is the second autoincrement in the table and is not a primary key. How (when|after) adding a field to overwrite all the data in the table, and assign the initial value of the field, for example, 100?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2019-02-06
@ThunderCat

ALTER TABLE `sometable` 
ADD COLUMN `id` INT AUTO_INCREMENT PRIMARY KEY,
AUTO_INCREMENT=100;

or create default then update id to id + 99

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question