As a newbie, I had failed to realize that when using auto-increment on the Primary Key field I didn't need to enter a value in that field as I populated my database manually one row at a time.

Subsequently, using phpMyadmin, I deleted rows and added rows and in between I un-set and reset the auto-increment function on the Primary Key field. I also Indexed and then Unindexed that same field.

Now I have this value showing in the Indexes grid of phpMyadmin:

Keyname: Primary, Type: Primary, Cardinality 23

But, when I add a new row, the value comes up as not 24 (as it should be) but 29.

Also, if I leave the value of the Primary Key blank (which is the correct method) but fill in the other values for the row and click Add Row and Return to the table row display page, I get 2 blank rows, with the value of the Primary Key field +5 of where it ought to be.

Is there a way to reset the auto-increment value?

Thanks. :bemused:

    What you could do is this - export your entire database using PHPmyAdmin by clicking the export tab at the top - then under the "Structure" tree - uncheck the box next to Add AUTO_INCREMENT value. Make sure that the box in the Data tree labeled "Complete inserts" is checked - and save your entire database to a .sql file.

    Drop the entire database. Then, execute the .sql file through PHPmyAdmin - that -- should -- do it for you if i'm not mistaken.

    Hope that helps!

      Thank you for the quick reply. I understood all of your instructions but the last bit about executing the database.

      Where do I do that from? :o

        DeadlySin3 didn't say anything about executing the database.

          Deadly wrote:

          Then, execute the .sql file through PHPmyAdmin - that -- should -- do it for you if i'm not mistaken.

          How do I "execute the .sql file"? Is this an Import?

          Sorry for not understanding, as I stated I am a newbie.

            At the top of the screen where the "Export" tab is you can click on the SQL tab - and you can either upload the .sql file from there or you can copy and paste all the sql instructions into the textarea and click submit.

            Hope that helps!

              Why mess with exporting and importing a database/table? Just execute this SQL statement:

              ALTER TABLE `tableName` AUTO_INCREMENT = 24;

              Replacing 24 with the next unused sequential number.

                Write a Reply...