List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:June 16 1999 11:00am
Subject:Re: auto increment
View as plain text  
proneone wrote:
> hi all -
> i have a table with about 70 rows and 8 cols.  i simply want to add a
> colum that will index each row from 0 or 1 to 69 or 70 (doesnt matter
> where the index starts)
> i just dont want to have to create a colum and fill in the rows myself
> with the numbers.  can this be done with a simple command in mysql?
> thanx
> - s

This is untested, but should work:

alter table tablename add new_col int auto_increment primary key;

If it does not, dump the table out, drop and re-create, then reload the
data back it, and all inserts should change the auto_increment field.

Sasha Pachev (home) (work)
auto incrementproneone16 Jun
  • Re: auto incrementSasha Pachev16 Jun