SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    liv
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is it possible to reset Auto INCREMENT?

    i was wondering if it was possible to reset the increment back to 0, once all the data in the table is deleted??

    thanks in advance
    g

  2. #2
    SitePoint Addict psyon's Avatar
    Join Date
    May 2004
    Location
    Cedar Rapids
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe it is:
    Code:
    ALTER TABLE stuff AUTO_INCREMENT=1;

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If all the data is deleted:
    Code:
    TRUNCATE TABLE whatever;
    http://dev.mysql.com/doc/mysql/en/TRUNCATE.html

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    liv
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, is it possible to this without deleting the data do you kow?

  5. #5
    SitePoint Addict psyon's Avatar
    Join Date
    May 2004
    Location
    Cedar Rapids
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    ALTER TABLE stuff AUTO_INCREMENT=1;
    That will reset the AUTO_INCREMENT value to 1 or what ever the highest current value in the table is +1;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •