wobbily_col
wobbily_col

Reputation: 11879

MySQL can I insert specific ids into an auto-increment column

I accidentally deleted some rows in my database, but I have a copy of the data in a backup.

Is it possible to insert the rows back in with the same id (auto-increment field). Or do I have to use the auto-increment generated id then update all the relationships manually?

Upvotes: 10

Views: 11353

Answers (1)

Leonid Shevtsov
Leonid Shevtsov

Reputation: 14179

You can, just by setting the field when INSERTing. Autoincrement only works if no value is specified for the field.

Upvotes: 22

Related Questions