I have an extremely large database table - nearly 20 million records.
The records do not have a unique ID number. So, I've inserted the new field.
Now, I would like to populate it with ID numbers, increasing by 1, starting with the first ID number being 10,000,001.
FYI - I am using WAMP on a local machine and I've dialed all my max times upto 5000 seconds and dialed up several other variables in php.ini and mysql.ini in order to do the upload in the first place (which took more than 10 hours!!).
In the past, or with other DB's, I might have exported the data into excel and then whipped up some text to paste back into phpmyadmin to UPDATE the records. This is fine when working with 5K records, or even 100K records, but this seems unmanagable with 20 million records.
Thanks in advance!!
Just run these two queries one after the other in the SQL tab:
ALTER TABLE mytable AUTO_INCREMENT=10000001;
ALTER TABLE mytable ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
MySQL will then create the id
field and fill it in sequentially starting at 10000001.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With