Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Updating auto_increment fields ?
I have a table with quiz questions. Each question has a unique ID, based on
an auto_increment field.
Now I've discovered that with deleting rows from the table the deleted ID's
are not reissued. Makes sense, just thought of that a bit late.

How can I simply re-index or update or how one would call it, the columns
holding the ID numbers ? Is there a ready-made mysql command or do I have to
load all rows in PHP and modify where necessary ?

TIA
Pjotr



Report this thread to moderator Post Follow-up to this message
Old Post
Pjotr Wedersteers
08-30-04 01:57 PM


Re: Updating auto_increment fields ?
*** Pjotr Wedersteers wrote/escribió (Mon, 30 Aug 2004 10:47:43 +0200):
> I have a table with quiz questions. Each question has a unique ID, based o
n
> an auto_increment field.
> Now I've discovered that with deleting rows from the table the deleted ID'
s
> are not reissued. Makes sense, just thought of that a bit late.
>
> How can I simply re-index or update or how one would call it, the columns
> holding the ID numbers ? Is there a ready-made mysql command or do I have 
to
> load all rows in PHP and modify where necessary ?

I wouldn't play with that. If auto-generated IDs are not valid for you,
just quite using them. You can make your column UNIQUE to prevent
duplicates and assign your own IDs from the very beginning.


--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--

Report this thread to moderator Post Follow-up to this message
Old Post
Alvaro G Vicario
08-30-04 01:57 PM


Re: Updating auto_increment fields ?
There is no automatic way to rebuild a table and have the missing
auto-increment values used up. This could cause a serious problem if one of
these primary keys was a foreign key on another table.

Why do you need a deleted row to be re-used? What problem does it cause to
have a missing id number?

--
Tony Marston

http://www.tonymarston.net


"Pjotr Wedersteers" <x33159@westerterp.com> wrote in message
news:4132e9af$0$65124$e4fe514c@news.xs4all.nl...
>I have a table with quiz questions. Each question has a unique ID, based on
> an auto_increment field.
> Now I've discovered that with deleting rows from the table the deleted
> ID's
> are not reissued. Makes sense, just thought of that a bit late.
>
> How can I simply re-index or update or how one would call it, the columns
> holding the ID numbers ? Is there a ready-made mysql command or do I have
> to
> load all rows in PHP and modify where necessary ?
>
> TIA
> Pjotr
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Tony Marston
08-30-04 01:57 PM


Re: Updating auto_increment fields ?
Tony Marston wrote:
> There is no automatic way to rebuild a table and have the missing
> auto-increment values used up. This could cause a serious problem if
> one of these primary keys was a foreign key on another table.
>
> Why do you need a deleted row to be re-used? What problem does it
> cause to have a missing id number?
>
>
> "Pjotr Wedersteers" <x33159@westerterp.com> wrote in message
> news:4132e9af$0$65124$e4fe514c@news.xs4all.nl... 

I intended on using a random ID number 1..num_rows and retrieving the
question with that ID from the table. I will now have to do an additional
check to see whether mysql_reult for that random number holds a row of data
indeed. No biggy in this case. I think in retrospect in this case
auto_increment just wasn't the field to use. I had better used a UNIQUE id
field I numbered myself.

Thanks both for the advise. I somehow already figured tampering with
auto-increment data wasn't a wise plan.
Pjotr



Report this thread to moderator Post Follow-up to this message
Old Post
Pjotr Wedersteers
08-30-04 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:53 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.