Page 1 of 1

can i alter a table column to make it auto increment?

Posted: Wed Jan 29, 2003 1:22 pm
by crimius
the column in question is the primary key.

there are already records in the table.

thanks :)

Posted: Wed Jan 29, 2003 2:10 pm
by BDKR
My guess would be no, but that's just a guess. auto_incrementing fields can't have duplicates as you know, but when the engine is told to change a field to auto_increment, does it check to see if dups exist? If it does and there are, I'm sure it would choke. And it should (!) or else your talking about a potential corruption of data. :evil:

Check the manual for your db and try to find out. :wink:

Cheers,
BDKR

Posted: Wed Jan 29, 2003 2:16 pm
by Stoker
Shouldn't be any problem at all if the column is Unique (Which it is if it is a primary key and not composed) and of some Integer type... Take a backup of your data before trying anyway to be safe..

another question

Posted: Wed Jan 29, 2003 4:12 pm
by crimius
Yah, all the entries for that column are unique.

I'm using MySQL...does anyone know the ALTER command for making that column auto increment?

Thanks for the info!

Try this

Posted: Fri Jan 31, 2003 4:17 am
by Caroline
I don't say it will work, but it may work

Use phpMyAdmin, browse to your table, click on change in the column field and make

Extra >>> Auto increment

Hope that work[/url]