#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Lindale, TX
    Posts
    257
    Rep Power
    15

    Auto Increment Question


    Hi,

    I am using an auto incrementing field.
    INT Type,

    If I delete ALL records using SQL delete statement, how can I just reset the auto incrementing field to start back over at 1?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    36
    Rep Power
    17
    I have never tested this but it sounds viable

    Code:
    truncate table TABLENAME
    Have you ever sat at a redlight for so long you thought the light was broken and just as you thought that it turned green???? Well me neither
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Lindale, TX
    Posts
    257
    Rep Power
    15
    Ah, Ill try it
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2003
    Location
    Washington, DC Metro
    Posts
    1,747
    Rep Power
    890
    john8675309 is almost correct, the syntax is TRUNCATE tablename;

    Edit: after reviewing the manual, the TABLE is optional. Both TRUNCATE TABLE and TRUNCATE do the same thing. My bad.
    Last edited by Adrastea0413; April 21st, 2006 at 02:12 PM.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Lindale, TX
    Posts
    257
    Rep Power
    15
    Cool, worked great thanks a bunch....
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Lindale, TX
    Posts
    257
    Rep Power
    15
    Actually it worked as he stated TRUNCATE TABLE tblename;

    Comments on this post

    • Adrastea0413 agrees : Heh. You must have typed that just as I was editing my post to say that both work. Well, at least we know! :)
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Lindale, TX
    Posts
    257
    Rep Power
    15
    Thanks guys...

IMN logo majestic logo threadwatch logo seochat tools logo