[thelist] Auto Increment in database - a goofy question I am sure

rudy r937 at interlog.com
Wed Apr 17 16:43:00 CDT 2002


> Don't do this if you are using the ID field
> as a foreign key in another table!!

note the exclamation points

good one, anthony


it sort of begs the question, doesn't it, as to what the purpose of the ID
field really is

if it's *not* a foreign key in some other table, just drop it!

if it *is* a foreign key in some other table, you may have to completely
renumber all related fields -- ugly, but it can be done with some sneaky
sql where the old ID and new ID temporarily co-exist in each affected table

if you want to keep the existing numbers, try just assigning it a new
create spec through the ALTER statement

   alter table T
     modify ID integer unsigned not null auto_increment

this is mysql syntax, and i'm sorry, i don't know if it'll work (i.e.
preserve existing numbers)

jay, what's an AI index?


rudy




More information about the thelist mailing list