Reinitializing an autoincrement column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrhitokiri
    New Member
    • Apr 2008
    • 35

    Reinitializing an autoincrement column

    i have been working on a project with an autoincrement column. as i tested continually, the increments reached about 2500. now, with the project finished, how do i reset the autoincrement counter back to zero? even if i erase all my data in the tables, the autoincrement keeps on counting higher than 2500. how do i get it back to zero?

    thanks!

    PS. im using phpmyadmin, if that's any help
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Helle there!

    You can use this:
    [php]
    ALTER TABLE `table_name`
    AUTO_INCREMENT = 0
    [/php]

    Cheers :)

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      This is NOT a php question, but a MySQL one. I will move this thread.\ to the MySQL forum.

      moderator

      Comment

      • ashokkumarpdi
        New Member
        • Apr 2008
        • 2

        #4
        Hi,

        if you want to delete all the records from the table, user the tuncate statement to delete all the records. It will delete all ur records and automatically rest ur auto increment value. Otherwise you have to rest the value manually by the alter table statement.


        Ex:

        TRUNACATE TABLE <table_name>;

        else

        use the above method.


        Regards,
        S.Ashokkumar

        Comment

        • jrhitokiri
          New Member
          • Apr 2008
          • 35

          #5
          Originally posted by ronverdonk
          This is NOT a php question, but a MySQL one. I will move this thread.\ to the MySQL forum.

          moderator
          oh, okay, im sorry. you could delete this now. problem solved.. ^_^

          thanks for those who helped out

          Comment

          Working...