Solved

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

Posted on 2008-10-23
5
322 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 500 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

707 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