Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-09-2005, 07:40 PM MySQL question
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Hey guys I am working on a project and I am a little stuck, hopefully you can give me a hand.

Can MySQL reuse empty auto_increment values without reordering existing ones?
i.e. Values 1 2 3 and 4 exist, but 3 is deleted, have next record be inserted into row 3 and not row 5.
Truly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-09-2005, 08:49 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
ok, let's start by saying that auto_increment values are not real primary keys, and so should be used with caution if using them as primary keys - which i think you are! I don't believe it is possible, because, while it is possible to reset the auto_increment, if using it for primary keys, an INSERT will cause an overwrite of anything with the same primary key - thus being rather useless!

I could be wrong though - can i ask why you need this to be done?? Check out the mySQL manual
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 07-10-2005, 07:51 AM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Trades: 0
When using AUTO_INCREMENT as an ID, if a row is deleted, that row ID will never be reused.

AUTO_INCREMENT values make for poor primary keys. There is always a better field and an AUTO_INCREMENTed ID is normally used for admin purposes rather than search queries.
Enigmatic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to MySQL question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23457 seconds with 12 queries