new value in database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

new value in database

Post by hrubos »

I use PhpMyAdmin to design database, And I have problem that sometimes I only try to insert some values then I delete it.But when I continue to insert new value, there is continueing id (id is autoincrement, example the last id : 25, but I deleted 25th value, I insert a new value and it is 26th value, not 25th however database are 25 values. I want that new value was inserted, is 25th value ).

How can I do to refresh database???
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

why? that's what the auto_increment is for... not to make sure every id is in order ??
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

Post by hrubos »

The Ninja Space Goat wrote:why? that's what the auto_increment is for... not to make sure every id is in order ??
because user complete information into database and so I have to make id autoincrement.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

users should not have access to the auto_increment value... and auto_increment value should have no really association with whatever it's used to identify. All it does is create a unique id for each record... there is absolutely NO reason why it should EVER have to be in perfect order. as long as it increments every time...
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

Post by hrubos »

The Ninja Space Goat wrote:users should not have access to the auto_increment value... and auto_increment value should have no really association with whatever it's used to identify. All it does is create a unique id for each record... there is absolutely NO reason why it should EVER have to be in perfect order. as long as it increments every time...
So I have one question

What will be id when deleting in database?New id is continue or have same value (I have shown a example).

Because I don't have experience with database. This is the first time I have worked in database.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do like many of us did when we were starting out with databases: try it and find out for yourself.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

As others have said, the purpose of an auto-increment field is to insure that there are no duplicate identifiers in a table. Users (and even administrators) should never be concerned about WHAT value it contains, only that it is unique. If that's not what you wanted, you should not have used an auto-increment field. Databases are not just glorified spreadsheets, they are based on strict mathematical set theory. If you are going to continue working with databases, I strongly recommend that you take a course in database theory.
Post Reply