Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mysql: AUTO_INCREMENT

    How would i reset the value, i have deleted every row but the id number still comes up as 300 or 301, 302 ect when i create a new row.
    how would i make this 0 ?

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    472
    Thanks
    1
    Thanked 0 Times in 0 Posts
    alter table (table name) drop column (id column)

    alter table (table name) add column (id column) mediumint not null auto_increment

    I type that a lot when people join my club twice.
    If you're reading this, it may already be too late!

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thanks
    but their isnt another way to do it without deleting the column?

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    472
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I don't think so.
    If you're reading this, it may already be too late!

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I believe you can specifically set the next auto-increment value using:

    PHP Code:
    "ALTER TABLE $tbl_name AUTO_INCREMENT = $value" 
    Where $value is whatever you want the id to be, although I've not tried it myself
    Last edited by delinear; 06-15-2005 at 10:30 AM.

  • #6
    Regular Coder
    Join Date
    May 2004
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i reset the auto inc value in phpmyadmin then looked at the code and this is what was returned:

    $sql = 'ALTER TABLE tablename PACK_KEYS =0 CHECKSUM =0 DELAY_KEY_WRITE =0 AUTO_INCREMENT =1';

    hope it helps
    c.c.


  •  

    Posting Permissions

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