Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 02-13-2005, 07:36 PM   PM User | #1
techgearfree
Regular Coder

 
Join Date: Jan 2005
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
techgearfree is an unknown quantity at this point
Restart Auto_increment

How do I restart a collumn with auto_increment. I want it to start counting up from 1 again.
techgearfree is offline   Reply With Quote
Old 02-13-2005, 09:09 PM   PM User | #2
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Why do you want to do that?
hemebond is offline   Reply With Quote
Old 02-13-2005, 09:43 PM   PM User | #3
techgearfree
Regular Coder

 
Join Date: Jan 2005
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
techgearfree is an unknown quantity at this point
I was testing on my website how it makes users. When someone signs up. Their info goes into a table. I no longer need to test it, so I deleted all the users that I made. But, now when I make a user, in the user id column that is auto increment, the first user is like #42 (where I left off).
techgearfree is offline   Reply With Quote
Old 02-13-2005, 09:55 PM   PM User | #4
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
And why is this a problem?

(drop and recreate the table)
hemebond is offline   Reply With Quote
Old 02-13-2005, 10:06 PM   PM User | #5
techgearfree
Regular Coder

 
Join Date: Jan 2005
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
techgearfree is an unknown quantity at this point
Just for organizational sake. Is there any way to get the current code for the table so I don't have to type it all in again?
techgearfree is offline   Reply With Quote
Old 02-13-2005, 10:17 PM   PM User | #6
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
If you use phpMyAdmin you can do a quick export. Otherwise, dump the table and edit out the data.
hemebond is offline   Reply With Quote
Old 02-14-2005, 12:43 AM   PM User | #7
andyede
Regular Coder

 
Join Date: Sep 2004
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
andyede is an unknown quantity at this point
or just let it carry on counting from where it is. Is there any reason it needs to start at 1?
andyede is offline   Reply With Quote
Old 02-14-2005, 07:19 AM   PM User | #8
BigToque
New Coder

 
Join Date: Jan 2005
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
BigToque is an unknown quantity at this point
The way to do this (the easy way) is with phpMyAdmin.

When looking at the table structure, drop the auto-incrementing field, then recreate it. All entries will be renumbered starting from 1.
BigToque is offline   Reply With Quote
Old 02-15-2005, 02:06 PM   PM User | #9
kenetix
New Coder

 
Join Date: Feb 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
kenetix is an unknown quantity at this point
you could drop and reinsert the table and then populate it with the values.
__________________
Kenetix:: Achieving more than the ordinary.
http://www.kenetix.net
kenetix is offline   Reply With Quote
Old 02-15-2005, 03:09 PM   PM User | #10
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,435
Thanks: 2
Thanked 38 Times in 38 Posts
Brandoe85 will become famous soon enough
You can try:
alter tableName auto_increment = 1;

Not tested though...
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:01 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.