Thread: mySQL add auto_increment?
is there way edit existing table , add auto_increment field? have table, , want each row have it's own "id." hashing multiple columns, think easier have auto increment field. have drop table , create new one?
hi, may able rebuild. i'm assuming have primary key in table? having quick stab @ adding auto increment attribute gives me this...
code:there can 1 auto column , must defined key
there way add row, not auto incremented (as have mess around primary key have knock on effects). 1 way this:
add new column:
then create counter:code:alter table mytable add idcol int not null;
then update rows include new number id:code:set @count = 0;
the problem is, won't automatically increment new tuples when added unless use count variable when insertingcode:update mytable set idcol = @count:=@count+1;
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] mySQL add auto_increment?
Ubuntu
Comments
Post a Comment