samedi 18 juillet 2015

Allocating from previous unallocated id in table?

Allocating old id's to new row added in a table. For example:

id | name
1  | n1
2  | n2
3  | n3
4  | n4

So if I delete row with id = 2,table will look like

id | name
1  | n1
3  | n3
4  | n4

Now I add another row, For this row is it possible that id = 2 is alloted in mysql. I can make a java program in which I find all missing id's between 1 to (highest id alloted) in table and giving one of those missing id to the new row.

Is it possible to do it in mysql. Here 'id' is primary key.

Aucun commentaire:

Enregistrer un commentaire