?
Solved

how can i reset my id numbers in mySQL so it starts to count from 1

Posted on 2008-10-23
5
Medium Priority
?
323 Views
Last Modified: 2013-12-07
because i deleted some data in between because they were duplicate,  the id numbers are not exactly what i want which are is a 100 it is now a 1035 i tried this but didnt work ...help

ALTER TABLE property.property p set id AUTO_INCREMENT=1;
0
Comment
Question by:Lucinda08
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Umesh
ID: 22789149
Try this...(backup before running below code incase restore)

Pls change these... ID - > your auto-increment column name
                               tableName -> change with actual table name


SET @var_name = 0;
UPDATE tableName SET ID = (@var_name := @var_name +1);
ALTER TABLE tablename AUTO_INCREMENT = 1;
0
 

Author Comment

by:Lucinda08
ID: 22789197
thanks but  what is var_name
0
 
LVL 26

Expert Comment

by:Umesh
ID: 22789231
Its a variable...
0
 

Author Comment

by:Lucinda08
ID: 22789269
sorry i'm a beginner to this do you mean i should give var_name any name i want
0
 
LVL 26

Accepted Solution

by:
Umesh earned 1500 total points
ID: 22793454
User variables are written as @var_name, where the variable name var_name may consist of alphanumeric characters from the current character set, ., _, and $

e.g Lucinda08 or ushastry
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to recover a database from a user managed backup
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question