I have a table having id set to auto increment.
I have records 1 to 10 and I have deleted records 3 and 7.
So is their any way I can add records 3 and 7 again?
I have a table having id set to auto increment.
I have records 1 to 10 and I have deleted records 3 and 7.
So is their any way I can add records 3 and 7 again?
Yes, you have to "force" the id.
INSERT INTO table (id, field1) VALUES (3, "value"); // id = 3
But if you let the id "null" or not set, it will be incremented :
INSERT INTO table (field1) VALUES ("value"); // id = 8
In Mysql You can override the auto-increment id simply assingning the value you need .. this is perfectly legal ..
so you can insert your row with id 3 and 7 using
insert into your_table (id, col1, col2 ..) values (3, 'value_for_col1', 'value_for_col2'...)
the autoincrement only works if no value is specified for the field, in other words you can insert the specifying the value of the field with autoincrement, example: insert in db
.banks
(id
, description
,status
, created_at
,updated_at
) values ('3', 'Central Bank', '1', '2017-04-14 10:30:22', null);