2 Replies - 215 Views - Last Post: 25 April 2013 - 11:33 AM

#1 msz_900  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 09-February 11

remove index value in database php

Posted 25 April 2013 - 11:27 AM

HY to every one!
i attach a picture of my database..
the problem is that when i remove a record from database and insert new one then it will start with next index..
for example if i refome a record placed in location 1 then insert new one, the id of the new one is not 1, it take id number 2.. why?
can any have any idea?

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: remove index value in database php

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,045
  • Joined: 08-June 10

Re: remove index value in database php

Posted 25 April 2013 - 11:32 AM

if the ID field is defined as AUTO_INCREMENT, this is the way it works.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8939
  • View blog
  • Posts: 33,521
  • Joined: 12-June 08

Re: remove index value in database php

Posted 25 April 2013 - 11:33 AM

Why would you think it would fill in any gaps? Why *WOULD* you need it to do that?

Auto increment increments the last indexed value inserted..

so if you have indexes:
1
2
3
4

and remove 3 leaving:
1
2
4

The auto increment wont' search for the gap in 3 and use that again.

Over all it seems like a bad practice.. say something goes haywire.. and yes, you may have deleted 3, but if you need to scour back in the logs for 3's interactions and activity it becomes substantially harder if you keep recycling 3.

Not to mention has a max value of '2147483647'.. so you have a bit of room to add rows.

https://dev.mysql.co...eger-types.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1