Mysql auto increment help
I have table with fields like id,title,no,url.
I want to auto increment id field
the table already has 1000 records in it with already some assigned ids
Now i want to auto increament the records that are newly inserted only .开发者_运维百科i do not want to auto increment the already present 1000 records .
Is there way i can do this???
ALTER TABLE tablename MODIFY id integer (11) auto_increment;
Just set column to autoincrement. It will increment only new ids, and will set the autoincrement to max(id) + 1. Even when the column is autoincrement, you can set a value, and you'll change the autoincrement counter.
Please note, you have to create index on id, in order to make it an auto-increment field.
yeah, just add auto increment to the field that has the ids already. The ids must be unique. The next auto_increment will be on the highest id present in the table....Try to use phpmyadmin
Check the largest value of the id
SELECT MAX (ID) FROM TABLE
and make the starting index for this table from the next value (+1)
精彩评论